求助
#include<iostream>
using namespace std;
class Name
{
public:
char name;
Name(char b):name(b){}
};
class Dog:public Name
{
public:
dog(int n,char c):Name(c),weight(n){}
void getWeight(){cout<<weight<<" "<<name;}
private:
int weight;
};
int main()
{
Dog a(80,'d');
a.getWeight();
return 0;
}
--------------------Configuration: dxc6 - Win32 Debug--------------------
Compiling...
dxc6.cpp
H:\dxc6\dxc6.cpp(14) : error C2065: 'c' : undeclared identifier
H:\dxc6\dxc6.cpp(14) : error C2057: expected constant expression
H:\dxc6\dxc6.cpp(14) : error C2656: 'dog' : function not allowed as a bit field
H:\dxc6\dxc6.cpp(14) : error C2061: syntax error : identifier 'n'
H:\dxc6\dxc6.cpp(14) : error C2143: syntax error : missing ';' before '{'
H:\dxc6\dxc6.cpp(14) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
H:\dxc6\dxc6.cpp(26) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
dxc6.obj - 1 error(s), 0 warning(s)