I am having problems with the . operator I thought i had it right but it keeps giving me problems on the line myBike.Bicycle(24,17); it won't compile.

// This program is designed to imput data and 
// output the data for bike gear and sockets. 

#include <iostream>
using namespace std;

class Bicycle
{
public:
	Bicycle(int = 20, int = 12);
	void printBicycle(); 
private:
	int wSize; 
	int gears; 
}; 
Bicycle::Bicycle(int w,int g)
{
	wSize = w; 
	gears = g; 
	if (wSize >= 15 || wSize <= 35)
		wSize = w; 
	else 
		wSize = 20; 
	if (gears >= 5 || gears <= 20)
		gears = g; 
	else 
		gears = 12;
}
void Bicycle::printBicycle()
{
	cout << "Bicycle Information:\n"; 
	cout << "Wheel size: " << wSize << endl; 
	cout << "Number of gears: " << gears << endl; 
}

int main()
{
	Bicycle myBike; 

	myBike.Bicycle(24,17); 
	myBike.printBicycle(); 
	
	return 0; 
}

you can't call the constructor like you did in main())

int main()
{
	Bicycle myBike(24,17); 
	myBike.printBicycle(); 
	
	return 0; 
}

Thanks Ancient Dragon, I see what I was doing now.

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.