Syntax I've never seen before

Started by
16 comments, last by codingo 10 years, 7 months ago

I'm implementing a licensing api that has lib files written in C (which may have something to do with the exotic syntax). My application is written in C++ and I've never used C before. It looks like this:


License::License(int productID, const wstring version, etc)
{
     d_LicenseFilePath = L"";//?????????????
}

can't make sense of the: L"" value. Is there a guru out there that knows?

Advertisement

It marks the string literal as a wide character string literal, meaning that each element of the string is a wchar_t rather than a normal char.

i c, thank you

@SiCrane Is that C syntax?

Yes, it was added in the 1990 version of the C standard.

Does that mean that it is common to intermingle C syntax within C++ code?

It's also legal C++ syntax.

i C, thanks SiCrane.

Though you know that that function is C++, and not C, because it uses std::wstring (the wide char version of std::string).

(It's also definitely a C++ piece of code, because it's in a class constructor).

L"" is C++ just as much as L"" is C, so here it wouldn't be considered "intermingling" C and C++, but just C++ code.

What I mean to say is, don't think of L"" as 'C'. It's fully C++ even if C also has that feature. C also has variables, but when you encounter variables in C++, you don't think of variables as "Oh, that's a C thing".

in that sence couldn't you say the same thing about C in its entirety since C++ is a subset of C?

Which leads to the question: if "wstring d_LicenseFilePath;" was declared as a private member var of the class, why establish the wstring literal type again in the constructor?

This topic is closed to new replies.

Advertisement