visual studio fatal error

Mar 20, 2013 at 7:52am
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
[code]class distance
{private: int f ;
          float i; 
public: distance():f(0),i(0.0)
		{}
		
	

	void get_list()
	{ \\geting data from user
	}
	distance operator+=(distance d)
	{
	\\containing body of operator
}
}	
	int main()
	{	distance d1,d2,d3;
		d1.get_list();
	d3=d1+d2;
	cout<<"1st distance is: "<<d1<<endl;
	cout<<"2nd distance is : "<<d2<<endl;
	cout<<"Sum is: "<<d3;
	
	return 0 ;
	} 
[/code]


Hello! kindly help me in removing this errorm\ its urgent
Last edited on Mar 20, 2013 at 7:57am
Mar 20, 2013 at 8:28am
What error?

You need to post the actuial error the compiler generated.

You're using the wrong slashes for your comments.
Mar 20, 2013 at 8:30am
your comment slashes should be // and not \\

you have not ended your class dec with ';'

you have not supplied a + operator for your distance class

you need #include<iostream> and include the std namespace.


Mar 20, 2013 at 8:32am
1) comments are "//", not "\\"
2) you forgot ';' after class definition (Line 16)
3) There is std::distance class, delete using namespace std; from your program. (I congrats you, you run into name collision :) )
4) You didn't define operator+ for your class.
Mar 20, 2013 at 8:40am
first of all the comment line is this // not this \\
the second thing there an error here: distance operator+=(distance d) there is no = in the operation overloading that means it became like this distance operator+(distance d)
the third thing is you forgot the semicolon after the } of the class
and last you cant use the default output operator << with class you have to overloaded it too.


Mar 20, 2013 at 9:07am
@student 2341:
i dont know wat ur trying to do, if u had gone through the code atleast once, u would have spotted all these errors even with very basic programming knowledge, please try to do things yourself before posting.
Mar 20, 2013 at 6:02pm
it is "unexpected end of file" error please help me remove this
Topic archived. No new replies allowed.