Correct errors

Please someone correct errors below please thanks

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include<iostream>

using namespace std;

class student
 {



    // member data
      private int rollNum;
      private string name;

// constructor 
student()
{
rollNum=12;
name="hello";
}

student(int g)
{
rollNum=g;
name="hello";


student(int i,string j)
{
rollNum=i;
name=j;

}


// member functions




   public void input(void)
     {
         cout<<"enter your roll number ";
         cin >>rollNum;
         cout<<"enter your name ";
         cin >>name;

     }
 

   public void output(void)
    {
       cout<<endl<<"your roll number is : "<<rollNum;
       cout<<endl<<"your name is : "<<name;
 

    }


} // student class end here 

void main()
{

student st1=student();
student  st1=student(34,name);
st1.output();
 st1.input();
 st1.output();
student st2;
st2.input();
st2.output();
st1.output();
}
closed account (48T7M4Gy)
Please someone correct errors below please thanks

11:15: error: expected ':' before 'int' 
12:15: error: expected ':' before 'string' 
73:1: error: expected '}' at end of input In constructor 'student::student(int)': 
27:8: error: expected primary-expression before '(' token 
27:9: error: expected primary-expression before 'int' 
27:22: error: expected primary-expression before 'j' 
40:4: error: expected primary-expression before 'public' 
50:4: error: expected primary-expression before 'public' In member function 'void student::main()': 
65:10: error: redeclaration of 'student st1' 
64:9: note: 'student st1' previously declared here 
65:29: error: no matching function for call to 'student::student(int, std::string&)' 
65:29: note: candidates are: 
21:1: note: student::student(int) 
21:1: note: candidate expects 1 argument, 2 provided 
15:1: note: student::student() 
15:1: note: candidate expects 0 arguments, 2 provided 
5:7: note: student::student(const student&) 
5:7: note: candidate expects 1 argument, 2 provided 
5:7: note: student::student(student&&) 
5:7: note: candidate expects 1 argument, 2 provided 
66:5: error: 'class student' has no member named 'output' 
67:6: error: 'class student' has no member named 'input' 
68:6: error: 'class student' has no member named 'output' 
70:5: error: 'class student' has no member named 'input' 
71:5: error: 'class student' has no member named 'output' 
72:5: error: 'class student' has no member named 'output' At global scope: 
73:1: error: expected unqualified-id at end of input 
Last edited on
can you correct the below?

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
#include<iostream>

using namespace std;

class student
{
public: int roll;
public: string: name;

	student{
		roll = 000;
	name = 000;

	}
		public void input(void)
	{
		cout << "Enter your Roll Number";
		cin >> roll;
		cout << endl << "Enter Your Name";
		cin >> name;
	}
        public void output(void)
		{
		cout << "Your Roll Number :" << roll;
		cout << endl << "Your Name: " << name;

	}
};

void main()
{
	student st1;
	st1.input();
	st1.output();
	st2.input();
	st2.output();
}
Are you having trouble taking a hint?

If you want is to help you with your code, you should tell us what the errors are.
Last edited on
i'm new in c++ and in below code there are alot of error so i want you to copy the code in your editor and correct the errors

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
#include<iostream>

using namespace std;

class student
{
public: int roll;
public: string: name;

	student{
		roll = 000;
	name = 000;

	}
		public void input(void)
	{
		cout << "Enter your Roll Number";
		cin >> roll;
		cout << endl << "Enter Your Name";
		cin >> name;
	}
        public void output(void)
		{
		cout << "Your Roll Number :" << roll;
		cout << endl << "Your Name: " << name;

	}
};

void main()
{
	student st1;
	st1.input();
	st1.output();
	st2.input();
	st2.output();
}
line 18:
no operator ">>" matches these operands first


closed account (48T7M4Gy)
8:17: error: 'name' was not declared in this scope
 8:17: error: bit-field '<anonymous>' with non-integral type 
10:9: error: expected unqualified-id before '{' token 
15:10: error: expected ':' before 'void' 
22:16: error: expected ':' before 'void' In member function 'void student::input()': 
20:10: error: 'name' was not declared in this scope In member function 'void student::output()': 
25:36: error: 'name' was not declared in this scope At global scope: 
30:11: error: '::main' must return 'int' In function 'int main()': 
35:2: error: 'st2' was not declared in this scope


That's the error latest list. I'll give you a tip about debugging MAhmed. Fix the first error. Recompile and address the first error in that new list.

Second tip: You must read the numbers and 8:17 means your next error is in line 8.
Line 8: You're using string, but have not included the <string> header.
Line 8: Lose the : after string.
Line 10: Your constructor needs () after student.
Line 12: You can't assign an int to a string.
Lines 15,22: Lose the public
Line 30: main must be type int.
Lines 35,36: You haven't declared st2


Topic archived. No new replies allowed.