+ 1

Sepreat files for classes in C++

Sololearn not provide the exact program in this case I take video tutorials online but there code is not working on my PC.so I need the Full program of Sepreat files for classes.Help please

22nd Dec 2018, 8:40 AM
Saad Saleem
Saad Saleem - avatar
13 Respuestas
+ 5
File name: myClass.h #pragma once // not standard but is widely used instead of the preprocessor condition block class myClass { public: myClass(); void doStuff(); }; ~~~~~~~ File name: myClass.cpp #include <iostream> #include "myClass.h" myClass::myClass() { std::cout << "myClass object created.\n"; } void myClass::doStuff() { std::cout << "Doing stuff...\n"; } ~~~~~~~~ File name: main.cpp #include "myClass.h" int main() { myClass mc; mc.doStuff(); } ~~~~~~~~~ Output: myClass object created. Doing stuff...
22nd Dec 2018, 9:38 AM
Babak
Babak - avatar
+ 6
It's easy! Don't focus on the IDE. All you need to do is create 3 files as follow: myClass.h --> Class interface myClass.cpp --> Class implementation main.cpp --> Client program I'll give you a simple example in a couple of minutes.
22nd Dec 2018, 9:29 AM
Babak
Babak - avatar
+ 4
Here is a simple instruction if you get stuck somewhere. http://cs.uno.edu/~jaime/Courses/2025/devCpp2025Instructions.html
22nd Dec 2018, 9:46 AM
Babak
Babak - avatar
+ 3
What IDE are you using, now?
22nd Dec 2018, 9:42 AM
Babak
Babak - avatar
+ 2
I thought this video explained it okay easy, maybe it helps you. https://m.youtube.com/watch?v=9RJTQmK0YPI
22nd Dec 2018, 8:54 AM
HonFu
HonFu - avatar
+ 1
See this https://www.sololearn.com/learn/CPlusPlus/1955/ I need code for this program
22nd Dec 2018, 9:12 AM
Saad Saleem
Saad Saleem - avatar
+ 1
I finally make this simple one Main cpp #include <iostream> #include "Burrito.h" using namespace std; int main() { Burrito bo; return 0 } Header file #ifndef BURRITO_H #define BURRITO_H class Burrito{ public: Burrito(); }; #endif Last cpp file #include "Burrito.h" #include <iostream> using namespace std; Burrito::Burrito() { Cout << "Hello world "; }
22nd Dec 2018, 10:08 AM
Saad Saleem
Saad Saleem - avatar
+ 1
Last time I didn't know why this program not work But this time it work successfully. Thanks again C++ Soldier (Babak) And other helpers too
22nd Dec 2018, 10:10 AM
Saad Saleem
Saad Saleem - avatar
22nd Dec 2018, 8:46 AM
Saad Saleem
Saad Saleem - avatar
0
Sorry HonFu I can't understand because the compiler is totally different it's program is also different from solo learn and new Boston method.I need a program by the method of creating Class that open two new files and so on .See the solo learn explanation and tell me
22nd Dec 2018, 9:10 AM
Saad Saleem
Saad Saleem - avatar
0
I am going to try it now then I tell you
22nd Dec 2018, 9:40 AM
Saad Saleem
Saad Saleem - avatar
0
Dev C++ 5.11
22nd Dec 2018, 9:42 AM
Saad Saleem
Saad Saleem - avatar
0
OK let's see it
22nd Dec 2018, 9:46 AM
Saad Saleem
Saad Saleem - avatar