首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

C++新手!

2012-04-28 
C++新手求救!!!!!我早vs2011下面编译报错 求救:error C2065: person : undeclared identifiere:\app\myt

C++新手求救!!!!!
我早vs2011下面编译报错 求救:

error C2065: 'person' : undeclared identifiere:\app\mytest\mytest\main.cpp
error C2146: syntax error : missing ';' before identifier 'TomJack'
error C3861: 'TomJack': identifier not founde:\app\mytest\mytest\main.cpp
error C2065: 'TomJack' : undeclared identifiere:\app\mytest\mytest\main.cpp
error C2228: left of '.information' must have class/struct/unione:\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;
};


[解决办法]

C/C++ code
class person{public:    person(string n, int age, int height, float weight);    void information();private:    string name;    int age;    int height;    float weight;}; 

热点排行