The strange problem of c ++ programming in ubuntu-general Linux technology-Linux programming and kernel information. The following is a detailed description. Thank you for reading this post. Thank you.
I was a beginner in linux and used ubuntu 7.04. I wrote a program that the teacher talked about in class, but there were a lot of problems,
Source program:
# Include
# Include
Using namespace std;
Class Student
{
Public:
Student (char * pName = "no name ")
{
Cout <"Create a one student" < Strcpy (name, pName );
NoOfStudent ++;
Cout < }
~ Student ()
{
Cout <"Destructing one student" < NoOfStudent ++;
Cout < }
Static int number ()
{
Return noOfStudent;
}
Protected:
Static int noOfStudent;
Char name [40];
};
Static int Student: noOfStudent = 0;
Void fn ()
{
Student s1;
Student s2;
Cout < }
Void main ()
{
Fn ();
Cout <"Student: number ()" < }
Error message after compilation:
15.1.cpp: 24: Error: The program has a free '\ 357'
15.1.cpp: 24: Error: The program has a free '\ 275'
15.1.cpp: 24: Error: The program has a free '\ 235'
15.1.cpp: 30: Error: there are additional restrictions. 'student: 'on the member 'noofstudent'
15.1.cpp: 30: Error: iso c ++ does not allow the initialization of a very large static member 'noofstudent 'in the class'
15.1.cpp: 43: Error: expected '}' at end of input
15.1.cpp: In constructor 'student: Student (char *)':
15.1.cpp: 10: Error: 'name' has not been declared in this scope
15.1.cpp: In static member function 'static int Student: number ()':
15.1.cpp: 26: Error: expected primary-expression before 'protected'
15.1.cpp: 26: Error: expected '; 'before' protected'
15.1.cpp: At global scope:
15.1.cpp: 43: Error: expected unqualified-id at end of input
Among them, the "program has a free '\ 357'" error, I did not find it on the Internet, the other feeling is more strange, there is no such error in windows. Please help me. Thank you.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service