c++ - How to write a HelloWorld header files? -


i have following code in single cpp file (tested.cpp):

class tested {         private:                 int x;         public:                 tested(int x_inp) {                         x = x_inp;                 }                  int getvalue() {                         return x;                 } }; 

now want write header file code. how should look? , should change in cpp file after have header file. supposed header file should that:

class tested {    private:       int x;    public:       tested(int x);       int getvalue(); } 

then in cpp file should #include "tested.h". need replace whole class by:

tested::tested(int c_inp) {    x = x_inp; }  tested::getvalue(){    return x; } 

is right?

you need type type of return methods other constructor , destructor :

int tested::getvalue(){    return x; } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -