C++新手求救!!!!!
我早vs2011下面编译报错 求救:
error C2065: 'person' : undeclared identifier e:\app\mytest\mytest\main.cpp
error C2146: syntax error : missing ';' before identifier 'TomJack'
error C3861: 'TomJack': identifier not found e:\app\mytest\mytest\main.cpp
error C2065: 'TomJack' : undeclared identifier e:\app\mytest\mytest\main.cpp
error C2228: left of '.information' must have class/struct/union e:\app\mytest\mytest\main.cpp
以上是报错代码
以下是程序代码:
#include <iostream>
#include <string>
using namespace std;
void main()
{
string username = "jack";
int age= 21;
int height = 175;
float weight = 55.5;
person TomJack(username,age,height,weight);
TomJack.information();
}
class person
{
public:
person(string n, int age, int height, float weight);
void information();
private:
string name;
int age;
int height;
float weight;
};
person::person(string n, int a, int h, float w)
{
name = n;
age = a;
height = h;
weight = w;
};
void person::information()
{
cout<<age<<endl;
cout<<height<<endl;
cout<<weight<<endl;
cout<<name<<endl;
};