here's my question here
Construct a class named Coord that contain two floating –point data member named xval and yval , which will be used to store the x and y values of a point in rectangular coordinates. The function member should include appropriate constructor and display functions and friend function named conv_pol (). The conv_pol() function should accept two floating point member that represent a point in polar coordinates and convert them into rectangular coordinates .
and here's my coding..

using namespace std;

class Coord

	friend Coord conv_pol( float ,float);
float xval;
float yval;

	void print();



Coord::Coord(float x,float y)
	xval = x;
	yval = y;

void Coord::print()

Coord conv_pol(float x,float y)
   Coord temp;
   temp.xval = temp.yval*cos(temp.yval*3.142 /180);
   temp.yval = temp.yval*sin(temp.yval*3.142 /180);
   return temp;
int main()
	Coord a;

 return 0;

the error says no appropriate default constructor not initialized but then.. have already done Coord(float,float) which is the default constructor..
can anyone help me here.

8 Years
Discussion Span
Last Post by siddhant3s

Firstly, please you appropriate thread names, rather than things such as "Help me!" or "Problem!"

Your problem however is the fact that you are calling your constructer as Coord(), not Coord(float, float), and you haven't definded or declared a constructor of Coord().


int main()
	Coord a;//this thing is the trouble maker

Do you realize that you want to create object without giving any parameter. This was good if you had defined a no-argument constructor.
Although, there was no need for a no-argument constructor as the compiler generates auto-magically for you but only when, here is the key, you have not defined any type of constructor by yourself. Here you have already defined a two-argument constructor and hence the compiler wont generate any default constructor.
Now you have three choices,
1. Define a no-argument constructor.
2. Create your objects by Coord a(0.0,0.0)
3. Delete your two argument constructor.

Plz search the forum before posting such issues.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.