Hi.. can anyone tell me what is the meaning of this error??

[Error] cannot convert 'std::string {aka std::basic_string<char>}' to 'char' for argument '1' to 'char strcpy(char*, const char*)'

When I'm taking TeamName as char TeamName[30]; , the compiler shows linker error.
what could be the problem?
I use DEV C++ 5.2.0.3

#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<fstream>
#include<string>
#include<cstring>
using namespace std;
class team
{
    team *base;
    string TeamName;

    public:
        team()
        {
          base = NULL;  
        }
        void create_team();
        void front();
};


void team::create_team()
{
    string x;
    team *temp = new team;
    cout<<"ENTER THE TEAM NAME: ";
    cin>>x;
    strcpy(temp->TeamName,x);       //FACING ERROR HERE!!        
}

strcpy() works with c-strings and those are arrays of characters that have a '\0' terminating character. You are using a C++ string and they have the '=' operator overloaded so you just have to write string1 = string2; and that will copy the contents of string2 into string1.

I would not use strcpy() and I wouldn't make a new string variable 'x'. It looks like you could just write cin >> temp->TeamName; and that would work the way you want it.

Okay i'll implement that,
but now I'm getting this error

[Linker error] C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to `WinMain@16'

Any idea about this?

Do you not have a main() function in your program? If what you posted is your program and not just a snippet then you need to throw in main().

By default, class members are private. You cannot assign to temp->TeamName from a string. This is where a public setter method is appropriate, as in

class team
{
    string TeamName;
    .
    .
    .
public:
    setName(const string& name);
    .
    .
    .
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.