-6

I researched this question on Google and Stak Overflow but couldn't find an answer to it.

I am trying to find out what all information is stored in a .cpp file extension. Meaning, is it just code that has been compiled (meaning compiled code)? Does have an object file in it? Does it include an object in it? What exactly does it consist of?

Sean V
  • 7
  • 5
  • it is c++ source code – pm100 Jan 12 '18 at 23:28
  • 3
    I'm voting to close this question as off-topic because No effort to find an answer. – SoronelHaetir Jan 12 '18 at 23:32
  • It's just a plain text file containing the source code. – Barmar Jan 12 '18 at 23:37
  • I can't find an answer to this question specifically here on Stack Overflow or Google: https://www.google.com/search?q=what+is+stored+with+a+cpp+extension&rlz=1C1CHBF_enUS779US779&oq=what+&aqs=chrome.0.69i59l3j69i65l3.1654j1j7&sourceid=chrome&ie=UTF-8 – Sean V Jan 12 '18 at 23:40
  • Ok, thank you. I thought it was more than source code, such as compiled code, or executable code? – Sean V Jan 12 '18 at 23:42
  • I can't find a flat-out answer either, but if you read between the lines in the likes of [What is the difference between a .cpp file and a .h file?](https://stackoverflow.com/questions/875479/what-is-the-difference-between-a-cpp-file-and-a-h-file) you get a pretty good definition. – user4581301 Jan 12 '18 at 23:44
  • Ok, thank you pm100 and Bamar! I was totally overthinking it – Sean V Jan 12 '18 at 23:52

1 Answers1

0

The .h usually has the class definition (code)

#ifndef CLASS_T_H
#define CLASS_T_H

class class_t {
public:
    class_t();
    class_t(const class_t& o);

    ~class_t();

    class_t& operator=(const class_t& o);

private:

};

#endif

And the .cpp usually has the class implementation (code)

#include "class_t.h"

class_t::class_t() {

}

class_t::class_t(const class_t& o) {

}

class_t::~class_t() {

}

class_t& class_t::operator=(const class_t& o) {
    return *this;
}

You could use the class_t in another .cpp file by inclduing the .h file and compiling the cpp files into a binary executable. One of the cpp files would contain your main() method.

Abdul Ahad
  • 826
  • 8
  • 16