how to attach the class to my project

how to attach the class to my project

Page 1 of 1

3 Replies - 1343 Views - Last Post: 14 November 2006 - 12:16 PM Rate Topic: -----

#1 pazenlatierra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-November 06

how to attach the class to my project

Posted 14 November 2006 - 08:50 AM

:angry: I am ready to send a bunch of assignments to my prof BUT I can not figure out of how to

attach the class to my project, so I can send only one cpp file, and he can run the program from the executable.

I can run the program in my PC:

I do this

To set this from within your project go to Project Properties - Configuration Properties - C/C++ - General and add this directory to Additional Include Directories. Alternatively you could move the include file to the same directory as you *.cpp file.

BUT I know is a way to attach the class to the CPP file.

I will appreciate any help, I am been up all night working in those assignments, I just need to able to send it PLUS my email keep bouncing when I send two file, the cpp and the class separately

Than you

Is This A Good Question/Topic? 0
  • +

Replies To: how to attach the class to my project

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: how to attach the class to my project

Posted 14 November 2006 - 08:57 AM

You can simply put the class code in the same file as your main function, and send that. See the following:
include <iostream>
using namespace std;

class CRectangle {
	int x, y;
  public:
	void set_values (int,int);
	int area () {return (x*y);}
};

void CRectangle::set_values (int a, int b) {
  x = a;
  y = b;
}

int main () {
  CRectangle rect;
  rect.set_values (3,4);
  cout << "area: " << rect.area();
  return 0;
}


Taken from http://www.cplusplus...al/classes.html.

There is nothing saying that the class needs to be declared in a separate file, that is an exercise in efficiency and allows for the reusability and portability of the class for other applications.
Was This Post Helpful? 0
  • +
  • -

#3 pazenlatierra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-November 06

Re: how to attach the class to my project

Posted 14 November 2006 - 09:18 AM

NO...
The professor wants the class in a different file. I know there is way to attach the class to the cpp file . I have the class definition in a heaer file, I just nees to attached to the same file,so I can send it to the professor...

The program is working in my pc I have #include "fraction_class.h"

and the fraction_class.h is in a directory....IT JUST to send it to me prof so he can just run the exacutable....
I done it once I just can not do it again...thank you

View PostAmadeus, on 14 Nov, 2006 - 08:57 AM, said:

You can simply put the class code in the same file as your main function, and send that. See the following:
include <iostream>
using namespace std;

class CRectangle {
	int x, y;
  public:
	void set_values (int,int);
	int area () {return (x*y);}
};

void CRectangle::set_values (int a, int b) {
  x = a;
  y = b;
}

int main () {
  CRectangle rect;
  rect.set_values (3,4);
  cout << "area: " << rect.area();
  return 0;
}


Taken from http://www.cplusplus...al/classes.html.

There is nothing saying that the class needs to be declared in a separate file, that is an exercise in efficiency and allows for the reusability and portability of the class for other applications.

Was This Post Helpful? 0
  • +
  • -

#4 okyup  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 207
  • Joined: 06-November 06

Re: how to attach the class to my project

Posted 14 November 2006 - 12:16 PM

How about sending it the same way that you send the cpp file? :blink:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1