Good day people. I am new to OOP, so I asked a friend to give me a challenge. He gave me this question:
The volume of a cylinder is calculated using the formula V=πr2h. Where r is the radius and h is the height of the cylinder. Create a class called cylinder with its attributes. Create two objects of the class and calculate their combined volume by overloading the plus (+) operator. Out the result.
However, when compiling the .h file and then implementing what it will do on the .cpp file it gives me these error messages:
Cylinder.h: No such file or directory
reciper for target 'Cylinder.o' failed
.h file Code (Cylinder.h):
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
|
#ifndef CYLINDER_H
#define CYLINDER_H
class Cylinder {
public:
Cylinder ();
// Required Functions (setters):
void SetRadius( int R );
void SetHeight( int H );
void SetVolume( int R, int H, int PI );
// Getters:
double GetRaius ();
double GetHeight ();
double GetVolume ();
private:
// Required Variables:
double Height;
double Radius;
double PI;
return GetVolume();
};
#endif
|
.cpp file code (Cylinder.cpp):
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
|
#include "Cylinder.h"
Cylinder::Cylinder() {
PI = 3.14159;
Height = 0;
Radius = 0;
}
void Cylinder::SetHeight( int H ) {
Height = H;
}
void Cylinder::SetRadius( int R ) {
Radius = R;
}
void Cylinder::SetVolume( int R, int H, int PI ) {
int Volume = ( R*H*PI )*2;
}
void Cylinder::GetHeight() {
return Height;
}
void Cylinder::GetRaius() {
return Radius;
}
void Cylinder::GetVolume() {
return Volume;
}
|
Now, there is an Makefile.win erro which I dont understand anything.
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
|
# Project: Cylinder
# Makefile created by Dev-C++ 5.11
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
OBJ = "Users/KingShaq/Documents/Programming\ I/Cylinder.o"
LINKOBJ = "Users/KingShaq/Documents/Programming I/Cylinder.o"
LIBS = -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib" -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc
INCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include"
CXXINCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++"
BIN = Cylinder.exe
CXXFLAGS = $(CXXINCS)
CFLAGS = $(INCS)
RM = rm.exe -f
.PHONY: all all-before all-after clean clean-custom
all: all-before $(BIN) all-after
clean: clean-custom
${RM} $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)
"Users/KingShaq/Documents/Programming\ I/Cylinder.o": Users/KingShaq/Documents/Programming\ I/Cylinder.cpp
$(CPP) -c "Users/KingShaq/Documents/Programming I/Cylinder.cpp" -o "Users/KingShaq/Documents/Programming I/Cylinder.o" $(CXXFLAGS)
|
I would gladly appreciate your help!!