请问c++高手
请教c++高手
初学C++的菜鸟,开发平台为vc++6.0
创建了一个头文件 GradeBook.h
#include <iostream>
#include <string>
using namespace std;
class GradeBook
{
public:
GradeBook (string Name)
{
courseName=Name;
}
void setCourseName(string name)
{
courseName=name;
}
string getCourseName()
{
return courseName;
}
private:
string courseName;
};
在另一个文件,test.cpp,里面引用了这头文件
#include <iostream>
#include "GradeBook.h"
using namespace std;
int main()
{
GradeBook GradeBook1("struct function 1");
GradeBook GradeBook2("struct function 2");
cout << "grade1 :" << GradeBook1.getCourseName()
<< "grade2" << GradeBook2.getCourseName()
<< endl;
}
出现的错误:
--------------------Configuration: chapter1 - Win32 Debug--------------------
Compiling...
test.cpp
d:\program files\microsoft visual studio\myprojects\chapter1\test.cpp(12) : fatal error C1010: unexpected end of file while looking for precompiled header directive
执行 cl.exe 时出错.
test.obj - 1 error(s), 0 warning(s)
------解决方案--------------------
test.cpp开始加上 #include "stdafx.h" 试试
------解决方案--------------------
头文件重复包涵了。你在test.cpp只要#include "GradeBook.h"就可以了。
------解决方案--------------------
我这边能编译,你是不是工程建的不对。
------解决方案--------------------
你创建的应该是Win32 Console Application 才对呀
初学C++的菜鸟,开发平台为vc++6.0
创建了一个头文件 GradeBook.h
#include <iostream>
#include <string>
using namespace std;
class GradeBook
{
public:
GradeBook (string Name)
{
courseName=Name;
}
void setCourseName(string name)
{
courseName=name;
}
string getCourseName()
{
return courseName;
}
private:
string courseName;
};
在另一个文件,test.cpp,里面引用了这头文件
#include <iostream>
#include "GradeBook.h"
using namespace std;
int main()
{
GradeBook GradeBook1("struct function 1");
GradeBook GradeBook2("struct function 2");
cout << "grade1 :" << GradeBook1.getCourseName()
<< "grade2" << GradeBook2.getCourseName()
<< endl;
}
出现的错误:
--------------------Configuration: chapter1 - Win32 Debug--------------------
Compiling...
test.cpp
d:\program files\microsoft visual studio\myprojects\chapter1\test.cpp(12) : fatal error C1010: unexpected end of file while looking for precompiled header directive
执行 cl.exe 时出错.
test.obj - 1 error(s), 0 warning(s)
vc++6.0
c++
头文件,类
------解决方案--------------------
test.cpp开始加上 #include "stdafx.h" 试试
------解决方案--------------------
头文件重复包涵了。你在test.cpp只要#include "GradeBook.h"就可以了。
------解决方案--------------------
我这边能编译,你是不是工程建的不对。
------解决方案--------------------
你创建的应该是Win32 Console Application 才对呀