how to make additon function(for char)

i'm wanted to make addition function for ma class.

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
#include<string.h>
#include<iostream.h>
class string
{

private:
char str[40];
int a,b;

public:
getdata()
{
cin.getline(str,40);
}
string operator +(string ob)
              {
                            string t;
                            t.a=a+ob.a;
                            t.b=b+ob.b;
                            return(t);
              }
};
void main()
{

string a,b;
a.getdata();
b.getdata();
cout<<a+b;
}
I'm not very sure why would you want to do that since you have std::string in <string> header file . But i think you can look into str[40] until you meet the '\0' char and replace it with the chars from the string that has to be added and add '\0' char at the end of the resulted string
I don't know what weird mutant hidious fake version of C++ you are using but dude, please don't! Also, for that weird mutant hidious fake C++, you need an even more weird mutant hidious fake compiler, please just tell me what it is before getting rid of it for good as quick as possible(deinstall it and remove every trace!!!)!!!
I mean really, string.h, iostream.h, getdata vithout a type, void main(), return()... Really! My compiler gives me 5 errors about it!
Last edited on
Dev-C++ or Turbo C++ strikes again :(
Topic archived. No new replies allowed.