//write
    void write()
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        cout <<"";

    }


    template <typename A, typename ...B>
    void write(string argHead, B... argTail)
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        if (blnBlink==true)
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;

            GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
            string a;
            a=argHead;
            TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
            COORD Position;
            Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
            Position.Y=csbi.dwCursorPosition.Y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
        }

        else
            cout << argHead;
        write(argTail...);
    }


    template <typename A, typename ...B>
    void write(char *argHead, B... argTail)
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        if (blnBlink==true)
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;

            GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
            string a;
            a=argHead;
            TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
            COORD Position;
            Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
            Position.Y=csbi.dwCursorPosition.Y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
        }

        else
            cout << argHead;
        write(argTail...);
    }

    template <typename A, typename ...B>
    void write(A argHead, B... argTail)
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        if (blnBlink==true)
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;

            GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
            string a;
            //next 2 lines give me an error
            a=to_string(argHead);
            TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
            COORD Position;
            Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
            Position.Y=csbi.dwCursorPosition.Y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
        }

        else
            cout << argHead;
        write(argTail...);
    }

like you see, i'm overloading the write function for diferent types. but i get several errors on last write(). can anyone advice me?

"C:\Users\Joaquim\Documents\CodeBlocks\My Class\console.h|218|error: call of overloaded 'to_string(char*&)' is ambiguous|"

finaly i found my problem 'typename A' if i don't use it, i can't put it, or the compiler stays confuse...
so heres the correct code:

void write()
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        cout <<"";

    }


    template <typename ...B>
    void write(string argHead, B... argTail)
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        if (blnBlink==true)
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;

            GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
            string a;
            a=argHead;
            TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
            COORD Position;
            Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
            Position.Y=csbi.dwCursorPosition.Y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
        }

        else
            cout << argHead;
        write(argTail...);
    }


    template <typename ...B>
    void write(char *argHead, B... argTail)
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        if (blnBlink==true)
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;

            GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
            string a;
            a=argHead;
            TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
            COORD Position;
            Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
            Position.Y=csbi.dwCursorPosition.Y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
        }

        else
            cout << argHead;
        write(argTail...);
    }

    template <typename A, typename ...B>
    void write(A argHead, B... argTail)
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        if (blnBlink==true)
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;

            GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
            string a;
            a=to_string(argHead);
            TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
            COORD Position;
            Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
            Position.Y=csbi.dwCursorPosition.Y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
        }

        else
            cout << argHead;
        write(argTail...);
    }

thanks for all

i'm confused.. realy
if the code worked before, why i get again the errors?

void write()
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        cout <<"";
    }

    template <typename ...B>
    void write(string argHead, B... argTail)
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        if (blnBlink==true)
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;
            GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
            string a;
            a=argHead;
            TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
            COORD Position;
            Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
            Position.Y=csbi.dwCursorPosition.Y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
        }
        else
            cout << argHead;
        write(argTail...);
    }

    template <typename ...B>
    void write(char *argHead, B... argTail)
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        if (blnBlink==true)
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;
            GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
            string a;
            a=argHead;
            TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
            COORD Position;
            Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
            Position.Y=csbi.dwCursorPosition.Y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
        }
        else
            cout << argHead;
        write(argTail...);
    }

    template <typename A, typename ...B>
    void write(A argHead, B... argTail)
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        if (blnBlink==true)
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;
            GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
            string a;
            a=to_string(argHead);//error
            TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
            COORD Position;
            Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
            Position.Y=csbi.dwCursorPosition.Y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
        }
        else
            cout << argHead;
        write(argTail...);
    }

the exemple:

Console.write("\nhello mother\n");

error message:
"error: call of overloaded 'to_string(const char*&)' is ambiguous"

sorry but these don't make sence to me :(
plase can anyone advice me?

now works, because i used the const keyword... i know the const is for avoid the the variable been changed, but i don't understand these situation:

void write()
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        cout <<"";
    }

    template <typename ...B>
    void write(const string argHead, B... argTail)
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        if (blnBlink==true)
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;
            GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
            string a;
            a=argHead;
            TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
            COORD Position;
            Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
            Position.Y=csbi.dwCursorPosition.Y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
        }
        else
            cout << argHead;
        write(argTail...);
    }

    template <typename ...B>
    void write(const char *argHead, B... argTail)
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        if (blnBlink==true)
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;
            GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
            string a;
            a=argHead;
            TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
            COORD Position;
            Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
            Position.Y=csbi.dwCursorPosition.Y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
        }
        else
            cout << argHead;
        write(argTail...);
    }

    template <typename A, typename ...B>
    void write(const A argHead, B... argTail)
    {
        setlocale(LC_ALL, "en_US.UTF-8");
        if (blnBlink==true)
        {
            CONSOLE_SCREEN_BUFFER_INFO csbi;
            GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
            string a;
            a=to_string(argHead);
            TextBlink(a, csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y,csbi.wAttributes);
            COORD Position;
            Position.X=csbi.dwCursorPosition.X+strlen(a.c_str());
            Position.Y=csbi.dwCursorPosition.Y;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Position);
        }
        else
            cout << argHead;
        write(argTail...);
    }

can anyone explain to me why?

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.