|
I have a dynamic link library written in VC++6. I wrote some code with VC++2005 which calls the native VC++6 library. Whenever I pass std::string to the native library, the result is always garbage. However, this does not happen if I pass other types ...
Started by Lopper on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
In your case, VC6 and VC8 have different definitions of std::string (and the compilers.
Classes such as std::string aren't necessarily defined the same way in every version of the runtime by different compilers.
|
|
What is the difference between
private void DoSomething(int value) { value++; }
and
private int DoSomething(int value) { return value++; }
when used as either
DoSomething(value);
versus
value = DoSomething(value);
Started by JMs on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Try it: if you execute your first example, after DoSomething....
Value = DoSomething(value); std::cout<<value<<std::endl; DoSomething(value); std::cout< that exists inside the scope of DoSomething().
|
|
42 as unsigned int is well defined as "42U".
unsigned int foo = 42U; // yeah!
How can I write "23" so that it is clear it is an unsigned short int?
unsigned short bar = 23; // booh! not clear!
EDIT so that the meaning of the question is more clear:
template...
Started by moala on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Unfortunately, the only method defined for this is
One or two characters in single quotes ('), preceded by the letter L
According to http://cpp.comsci.us/etymology/literals.html
Which... .
Numeric literals cannot have short or unsigned short type.
You can't.
|
Ask your Facebook Friends
|
On Fri, 16 Jan 2009 14:24:59 -0800, Carl Forsman <fatwallet951@yahoo.com
are they basically the same?
except portablity where CString is only microsoft?
Started by Carl Forsman on
, 12 posts
by 5 people.
Answer Snippets (Read the full thread at omgili):
4) CString has an LPCTSTR (const TCHAR *), instead
you must ... .
3) CString is reference counted, instead I believe that std::string is not.
Something like
typedef std::basic_string< TCHAR
2) CString offers useful methods like Left.
|
|
Class A{ A(int a = 5){ DoSomething(); A(); } A(){...} }
Can the first constructor call the second one?
Started by MainID on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
I_,j_; }; int main() { A a1(10,11), a2(10); std::cout << a1.i_ << ", " << a1.j_ << std::endl << a2.i_ << ", " << a2.j_ << std::endl; return 0; }
*Hell to decide which construcotr to....
|
|
Hi,
I want to sort points_vec vector as shown in the pseudocode below. I want to sort this vector, by a coordinate value like x or y or z
class A{ std:vector<double*> points_vec; void doSomething(); }
Then, in method A::doSomething, I want sort ...
Started by memC on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
; } class A { std::vector<Point> pts_; void doSomething() { sort(pts_.begin(), pts_.end Point3D class not a couple doubles Define the less then operator for Point3D Just call std::sort(points points here } };
And use like:
....
|
|
Hello.
Always considering that the following header, containing my templated class, is included in at least two .CPP files, this code compiles correctly:
template <class T> class TClass { public: void doSomething(std::vector<T> * v); }; template...
Started by Chuim on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Template <> void TClass<int>::doSomething(std::vector<int> * v);
and put implementation into one of your cpp-files:
template <> void TClass<int>::doSomething(std.
|
|
Currently, I have this code to prepend a "tag" to an exception message which gives me a very light version of a stack trace:
try { doSomething(); } catch (std::exception& e) { int size = 8 + _tcslen(e.what()); TCHAR* error = new TCHAR[size]; _sntprintf...
Started by Etan on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Why don't you use std::string?
try { doSomething(); } catch (const std::exception& e) { throwwhat about something like this:
throw std::exception(std::string("myTag: ").append(e.what()).c_str compile in ....
Of string.
|
|
I have a templated class defined (in part) as
template <class T> MyClass { public: void DoSomething(){} };
If I want to call DoSomething from another class, but be able to do this for multiple 'T' types in the same place, I am stuck for an idea ...
Answer Snippets (Read the full thread at stackoverflow):
Class MyClass : public Base { public: void DoSomething(){} }; std::vector<Base *> objects this:
class Base { public: virtual ~Base(){} virtual void DoSomething() = 0; } template <class T>.
|
|
I need to pass a pointer through a scripting language which just has a double and string type, for this I only have to worry about 32-bit pointers.
Seeing as the pointers are 32-bit, I figured doubles had enough precision to safely store the pointer, ...
Started by Fire Lancer on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
std::ofstream *fs = new std::ofstream("example.txt"); double d = reinterpret_cast<unsigned>(fs); fs = reinterpret_cast<std::ofstream *>(static_cast<unsigned>(d));
Or else cast to std:....
Any shifting around.
|