Errors i Cant seem to Fix

1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.h(16): error C3646: 'Private' : unknown override specifier
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.h(16): error C2590: 'getName' : only a constructor can have a base/member initializer list
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.h(16): error C2533: 'Person' : constructors not allowed a return type
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.h(16): error C2556: 'Person::Person(void)' : overloaded function differs only by return type from 'Person::Person(void)'
1> c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.h(10) : see declaration of 'Person::Person'
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.h(17): error C2275: 'std::string' : illegal use of this type as an expression
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring(2062) : see declaration of 'std::string'
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.h(17): error C2461: 'Person' : constructor syntax missing formal parameters
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.h(17): error C2146: syntax error : missing ';' before identifier 'Name'
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.h(17): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.cpp(5): error C2761: '{ctor}' : member function redeclaration not allowed
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.cpp(6): error C2447: '{' : missing function header (old-style formal list?)
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.cpp(10): error C2039: 'getName' : is not a member of 'Person'
1> c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.h(8) : see declaration of 'Person'
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.cpp(12): error C2065: 'N' : undeclared identifier
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.cpp(18): error C2065: 'A' : undeclared identifier
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.cpp(65): fatal error C1075: end of file found before the left brace '{' at 'c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.cpp(23)' was matched
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.53
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 #include <iostream>
#include "Person.h"
#include <string>
using namespace std ;
Person::Person(string N,string A);
{
    N=Name;
	A=Age;

} string Person::getName()
{
	return N;

}

int Person::getAge()
{
	return A;

}

int main()
{
	int n,A;
	string N;
	{
    cout <<"Enter the number of  your siblings or friends"<< endl;
    cin >> n;

	int*MyS=new int[n];

	string*MyN=new string[n];

	int*MyA=new int[n];

	cout <<"Now for each of your sibling,enter their name and age"<<endl;
	cin>>N;
    cin>>A;
	
	for(int i=0;i<n;i++)
	{
		cin>>N;
		cin>>A;

		MyN[i];
		MyA[i];

	}

	cout<<"The names and ages of my sibling are:"<<endl;

	for(int i=0;i<n;i++)

		cout<<MyN[i]<<MyA[i]<<endl;
	delete []MyS;
	};

Last edited on
Feel free to ask us a question :p

This is suspicious:
1
2
3
4
5
6
Person::Person(string N,string A);
{
    N=Name;
	A=Age;

}


How are the data members declared in the class?
i hav a Person .h file withe the following;

#include <iostream>
using namespace std;
#include <string>



class Person
{
public:
Person();
Person(string N,string A);
void initialize(string N,int A);

int getAge();
string getName()
Private:
string Name;
string age;

};
You have an extra ';' on line 5 of your code, and you are missing a ';' after string getName() in your header file.

1
2
3
4
5
 string Person::getName()
{
	return N;

}


1
2
3
4
5
int Person::getAge()
{
	return A;

}


N, and A are not members of your class so you can't return them
Last edited on
As I mentioned, your constructor isn't quite right.

Also, your getter functions refer to variables that don't exist in that scope (N should be Name and A should be age).

The declaration of getName (in the header file) needs to have a semicolon at the end of it.

private is spelled with a lowercase 'p'.

You also are missing a closing brace at the end of your main function (perhaps remove the opening brace on line 26 and remove the semicolon from line 56.

You never actually create an object of the class.
hmmmm.. i thought i was supposed to create one @Danny Toledo
Last edited on
hmmmm.. i thought i was supposed to create one @Danny Toledo

Maybe you are, you don't really tell us much :p

1
2
3
4
5
6
7
Person::Person(string N,string A)//; someone covered this
{
    N=Name;    // you are assigning the member string Name to the argument N
	A=Age; // same with age and A. Switch it around so you assign N to Name
               // and A to age

}
the hwk is dealing with Dynamic allocation :Arrays of Class objects,we were given the Person.h file and asked to write the Person.cpp file and then complete the int main () parts
Last edited on
1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.h(14): error C2144: syntax error : 'int' should be preceded by ';'

1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.cpp(5): error C2761: '{ctor}' : member function redeclaration not allowed

1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.cpp(6): error C2447: '{' : missing function header (old-style formal list?)

1>c:\users\kelvin\documents\visual studio 2010\projects\person\person\person.cpp(18): error C2065: 'Age' : undeclared identifier
Thanks Took out the Person::Person section and syntax error are Gone but now have this odd error:

fatal error LNK1120: 1 unresolved externals
How are you compiling and linking the files?
ctrl alt F7 for compilng
Thanks Took out the Person::Person section and syntax error are Gone but now have this odd error:

fatal error LNK1120: 1 unresolved externals


If by Took out the Person::Person section you mean that you removed that section, that is incorrect. All you needed to do was remove the extraneous semi-colon at the end of line 5. If you completely remove the definition of Person::Person, the linker won't be able to find the definition, and it will not be able to resolve that reference leading to the error message you see.
will redo it again..
oh ok @cire....
i fixed it age vs Age in .h file duh moment there,however

error C2440: 'return' : cannot convert from 'std::string' to 'int'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Last edited on
Thanks alot!!! so far Guys for your help
Last edited on
Her is my output;does not seem right

Enter the number of your siblings or friends
2
Now for each of your siblings,Enter their name and age
ashley25
lily26
The names and ages of my sibling are:
ashley25-858993460
ashley25-858993460
Press any key to continue . . .
Topic archived. No new replies allowed.