why this doesnot work

in main.cpp==>

#include <bits/stdc++.h>
#include "myclass.h"
#include<string.h>

using namespace std;

int main()
{
string name="harshit";
myclass obj;
obj.printcrap(name);

return 0;
}

in myclass.h==>

#ifndef MYCLASS_H
#define MYCLASS_H

class myclass
{
public:
myclass();
void printcrap(string);
protected:
private:
};

#endif // MYCLASS_H


in myclass.cpp==>

#include <bits/stdc++.h>
#include "myclass.h"
#include<string.h>

using namespace std;

myclass::myclass()
{
}

void myclass::printcrap(string x)
{
cout<<"i am "<<x<<endl;
}
Not sure what's not working but here is the code that I put in main.cpp and it works.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include<string.h>

using namespace std;

class myclass
{
public:
    myclass();
    void printcrap(string);
protected:
private:
};



myclass::myclass()
{
}

void myclass::printcrap(string x)
{
    cout<<"i am "<<x<<endl;
}


int main()
{
    string name="harshit";
    myclass obj;
    obj.printcrap(name);
    
    return 0;
}
Topic archived. No new replies allowed.