我想在類中定義模板成員函數,並且每次嘗試構建此代碼時MSVC崩潰。我不確定這是否是Visual Studio 2008中的一個錯誤。下面是一個簡單的例子。微軟的C++優化編譯器已停止工作
testTemp.h
頭文件:
#pragma once
#include <vector>
#include <iostream>
class testTemp
{
public:
testTemp(void);
~testTemp(void);
template<typename T>
std::vector<T> m_vMonitorVec;
int MonitorSignal(T x, std::vector<T> vec, int len);
};
這裏是testTemp.cpp
:
#include "StdAfx.h"
#include "testTemp.h"
testTemp::testTemp(void)
{
}
testTemp::~testTemp(void)
{
}
template<typename T>
int testTemp::MonitorSignal(T inp, std::vector<T> monVec, int len)
{
return 0;
}
和stdafx.h中是:
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
我在2008年MSVC運行此,每當我嘗試構建此代碼,我得到以下崩潰:
stdafx.h中是否有任何內容? – 2014-11-24 20:17:40
@Tim請參閱編輯 – Samer 2014-11-24 20:19:06
是的。編譯器不應該*崩潰*,獨立代碼的好壞。也許重新安裝等幫助。 – deviantfan 2014-11-24 20:19:08