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..

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


class Coord

{
	friend Coord conv_pol( float ,float);
private:
float xval;
float yval;

public:
	void print();

	Coord(float,float);


};

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


void Coord::print()
{
	cout<<'('<<xval<<','<<yval<<')'<<endl;
}

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;
	a=conv_pol(10,210);
	a.print();


 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.

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().

Chris

Member Avatar for jencas

Here

Coord conv_pol(float x,float y)
{ 
   Coord temp;

You have no parameterless ctor!

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.