containers

I am creating a program that will calculate the size of a circular container. i am getting the following error error "C4430: missing type specifier - int assumed. Note: C++ does not support default-int". I am very new to c++ and im not sure what i did wrong. everything appears to me to be correct in this header file. any help someone more knowledgable can provide would be appreciated...

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef CIRCLETYPE_H
#define CIRCLETYPE_H
#include<iostream>

using namespace std;

class circleType
{
private:
	double centerX;
	double centerY;
	double radius;
public:
	cirlceType();
	circleType( double );

	void setRadius( double );
	double getRadius();

	double area();
	double circumference();
	void print;
};

circleType::circleType()
{
	radius=0;
}

circleType::circleType( double r)
{
	radius=r;
}

void circleType::setRadius( double r)
{
	if( r >= 0 )
		radius = r;
	else
		radius = 0;
}

double circleType::getRadius()
{
	return radius;
}

double circleType::area()
{
	return 3.1416*radius*radius;
}

double circleType::circumference()
{
	return 2*3.1416*radius;
}
#endif CIRCLETYPE_H 
line 22. you are declaring a variable of type void. This is not allowed.

You probably meant to make it a function. In which case it is missing parenthesis.


Also for the future: it helps if you tell us what line the error occurs on.
First of all in your class you should list void print(); so that you're more correct. I also don't see a definition of void circleType::print(). That might be your problem. Everything else seems correct unless the error is in your main() function.
The error is happening on line 14.

I corrected the missing () from my print fuction
class circleType

1
2
public:
	cirlceType();



circleType
cirlceType();


The phaonmeal pweor of the hmuan mnid aoccdrnig to a rscheearch at
cmabrigde uinervtisy, it deosn't mttaer in waht oredr the ltteers in,
Jsut taht the frist and lsat leettr are in the rgiht spot.
the rset can be a taotl mses and you can sitll raed it wouthit a porbelm.
Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef,
but the wrod as a wolhe.

But computer are not human.
Last edited on
wow... cannot believe i overlooked that... thank you

one more problem I am having now that i fixed that. in my .cpp file

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
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include "cylinderType.h"

using namespace std;

int main()
{

	double radius;
	double height;
	double costPerLiter;
	double paintCost;
	

	cout << "Welcome to the shipping and painting calculator!" << endl;
	cout << "Please enter the radius of the base of the container in feet: ";
		cin >> radius;

	cout << "Thank you" << endl;
	cout << "Next, please enter the height of the container in feet: ";
		cin >> height;

	cout << "Thank you" << endl;
	cout << "Next, please enter the shipping cost per liter: ";
		cin >> costPerLiter;

	cout << "Thank you" << endl;
	cout << "Next, please enter the paint cost per square foot: ";
		cin >> paintCost;

	cout << "Total Shipping Cost :$" << cylinder.volume() * 28.32 * costPerLiter << endl;

	cout << "Total Paint Cost :$" << cylinder.area() * 28.32 * paintCost << endl;

	system( "pause" );
	return 0;

}


I am getting the error that cylinder has not been declared (lines 31-33). I am referencing the cylinder class and the functions volume and area? so i do not need to declare it as a variable right? this is my cylinder header file. (volume and area are on lines 47-55)


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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef CYLINDERTYPE_H
#define CYLINDERTYPE_H
#include "circleType.h"
#include <iostream>

using namespace std;

class cylinderType :public circleType
{

private:
	double height;
	double centerX;
	double centerY;

public:
	cylinderType( double, double );
	cylinderType();
	double area();
	double volume();
	double getHeight();
	void setHeight( double );
	void print();

};

cylinderType::cylinderType()
{
	height = 0;
}

cylinderType::cylinderType( double r, double ht ):circleType(r)
{
	height = ht;
}

void cylinderType::setHeight( double h)
{
		height = h;
}

double cylinderType::getHeight()
{
	return height;
}

double cylinderType::area()
{
	return 2 * circleType::area() + 2 * 3.1417 * circleType::getRadius() * getHeight();
}

double cylinderType::volume()
{
	return circleType::area() * getHeight();
}

#endif CYLINDERTYPE_H 
Last edited on
You have a cylinder class, but you havent defined a cylinder at all in the main... so the variable cylinder doesnt exist.

"double radius;
double height;
double costPerLiter;
double paintCost;"

You'll need a "cylinderType myCylinder"
then use that variable to access the members...

probably worth throwing in after:
" cout << "Thank you" << endl;
cout << "Next, please enter the height of the container in feet: ";
cin >> height;"

as "cylinderType cylinder(radius, height);"
thank you
Topic archived. No new replies allowed.