954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

no appropriate default constructor available error

I'm trying some code with classes but get these errors:

overloaded member function not found in 'Point'
'Point' : no appropriate default constructor available

#include <iostream>

using namespace std;

class Point
{
public:
	Point(float f_x, float f_y, float f_z);

private:
	float x, y, z;

protected:
};

Point::Point()
{
	cout << "We're in the default constructor" << endl;
}

Point::Point(float f_x, float f_y, float f_z)
{
	cout << "We're in the constructor with arguments" << endl;
}

void main()
{
	Point myLocation;
}


Anyone see where I'm going wrong?

En-Motion
Light Poster
25 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

You are passing no parameters to the Point class's constructor. It expect 3 floats, during instantiation (Point myLocation). You need to give it three floats.

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

You forgot to add Point() constructor declaration in the class Point definition. Do it.

ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
 

I recognize this code, this is from 3DBuzz's tutorial. :)
You did not declare the default constructor in your class. In other words you do not have declaration for the constructor with no arguments. Watch the 'public section' closely.

BevoX
Junior Poster in Training
57 posts since Jan 2009
Reputation Points: 77
Solved Threads: 12
 

Cheers lads. Working fine now

I recognize this code, this is from 3DBuzz's tutorial. :)

It is indeed!! Find their tutorials fairly good

En-Motion
Light Poster
25 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You