I have a class called Sphere, and within it I have different attributes (actually just one at the time).
Sphere.cpp:
#include "sphere.h"
Sphere::Sphere(double arg_r) {
radius = arg_r; //Radius is defined in sphere.h as a double
}
In my main class, I want to create a new "sphere". (Not sure if this is even right).
Then I want to pass this instance of Sphere to ExampleClass.
Main.cpp:
int main(int argc, char* argv[]) {
Sphere sphere = Sphere(1.0);
ExampleClass ex = ExampleClass(sphere);
return 0;
}
ExampleClass.cpp:
#include "exampleclass.h"
#include "sphere.h"
ExampleClass::ExampleClass(Sphere s) {
// Some code that will use Sphere s
}
I've tried doing this (or variations close to this) and haven't had any success. I was hoping someone couldn't straighten things out for me.

New Topic/Question
Reply



MultiQuote





|