Hello,

I have 2 wstring variables:

std:wstring first =L"Jose";
std:wstring second = L"James";

How can I combine these variables:

first + second

gives an error in Visual Studio.

Cheers

Assuming the target is also a wstring type, this should work. IE:
std::wstring newstr = first + L" " + second;

Note that you left off the second colon in your variable definitions. This may be your problem. What error are you getting? The following is a test program that I just wrote to test this on Linux using GCC 4.4.7. It works fine and the output is "John Doe" as expected.

#include <string>
#include <iostream>

int main()
{
    std::wstring first = L"John";
    std::wstring second = L"Doe";
    std::wstring full = first + L" " + second;
    std::wcout << full << std::endl;
    return 0;
}

So, you live on the Ile-de-France? Paris is a pretty big place! :-) Where are you going to school?

commented: +1 for balance and peas. +8

I would have been a bit more snarky if you said you lived on the Ile de la Cite. :-) I don't think Notre Dame has student housing on the island... I spent a month on the Rive Gauche when I was a teen - even climbed to the top of Notre Dame with my father - no hunchback there though! What a dissapointment!

commented: Another for balance. +0
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.