#include<conio.h>
#include<string.h>
#include<iostream.h>
class String
{
private:
char str[40];
public:
void menu()
{
gotoxy(30,12);
cout<<"Menu";
gotoxy(30,14);
cout<<"1.Comparing Strings";
gotoxy(30,16);
cout<<"2.Add to Strings";
}
void getdata()
{
cin.getline(str,40);
}
int operator ==(String i)
{
if(strlen(str)==strlen(i.str))
return 1;
else
return 0;
}
void showdata()
{
cout<<str;
}
String operator+(String ob)
{
String t;
strcpy(t.str,str);
strcat(t.str,ob.str);
return(t);
}
};
void main()
{
String a,b,c;
char ch;
clrscr();
a.menu();
ch=getch();
clrscr();
gotoxy(30,12);
cout<<"Enter first string";
a.getdata();
gotoxy(30,14);
cout<<"Enter second string ";
b.getdata();
clrscr();
switch(ch){
case'1':
if(a==b)
{
gotoxy(30,14);
cout<<"string are equal";
}
else
{
gotoxy(30,14);
cout<<"string are not equal";
}
break;
case'2':
c=a+b;
c.showdata();
break;
}
getch();
}
My guess is that he's trying to compile something targeted for the old DOS era Turbo C/C++ compiler from Borland with a newer compiler from another vendor (most likely GCC). That will not work out of the box, and this is not the right place to ask for solutions (it has nothing to do with the IDE).
[...]1. This is NOT a general programming board. "How do I write a program that....", "Can anybody teach me how to", "I have this homework", "My program doesn't run and I don't have the slightest idea of why because I'm a C++ newcomer", "What is a compiler", "What does gcc do" is the kind of questions that is FORBIDDEN to ask.
2. Compiler/Linker errors are NOT Code::Blocks errors. Usually, C++ newcomers tend to confuse the Editor/IDE (Code::Blocks) with the Compiler (MINGW / GCC). You may see some errors in the compiler output because you missed to do something right in your code. But that's not Code::Blocks troubleshooting, that's C++ troubleshooting and does not belong in here. If your program doesn't compile, READ THE C++ MANUAL.
[...]
4. Search before you post. If you've used other IDEs and you're moving to Code::Blocks, try reading the Wiki (e.g. http://wiki.codeblocks.org/index.php?title=FAQ) at the homepage, and if you're confused on how to set up things, SEARCH THE FORUM. Probably the answer you're looking for is in there. Remember, Google is your friend :)
[...]
Finale note: Ignoring these rules may result in the topic being (silently) locked and/or even removed completely without any notice.
[...]
More general help how to use our forum you'll find here (http://forums.codeblocks.org/index.php?action=help), too.