Im trying to do the copy part of a "deep copy" with my copy constructor:
class myClass
{
public:
myClass ( const char *cPtr, const float fValue )
myClass ( const myClass& myClassT );
private:
const char* &myAddress;
float MyFloater;
};
//myClass.cpp
myClass::myClass( const char *cPtr, const float fValue )
{
// Init...
Say I wanted to do an anonymous login, would it be to blank strings.
"" ""
?
...
I am trying to connect a CGI process to my windows service with a named pipe.
My code runs fine using another server on my development machine, but on IIS there are security issues when I call CreateFile() in the CGI process.
The Windows service is the Named Pipe Server and so the CGI process is trying to connect to that named pipe as a...
In VC++ 2003, I could just save the source file as UTF-8 and all strings were used as is. In other words, the following code would print the strings as is to the console. If the source file was saved as UTF-8 then the output would be UTF-8.
printf("Chinese (Traditional)");
printf("中国語 (繁体)");
printf("중국어 (번체)");
printf("Chinês (Tradicio...
Hi.
Simple question, is this valid C++:
class Foo
{
void Foo::doSomething();
};
The point of the question: is that repeated use of the class name and double colon before the method name valid inside the class declaration?
I'm having issues compiling code that does this using g++ 4.2.3. I would love to see a reference to somethin...
Some background:
As a personal project, I've been developing a kernel in c++. Things are going well, in fact I have very good support for much of c++ available in kernel land (I've implemented nearly the entire libc and libstdc++).
One of the more difficult and compiler specific things is RTTI and exception support. For now I'm disabli...
Duplicate of http://stackoverflow.com/questions/683013/interop-sending-string-from-c-to-c
I want to send a string from C# to a function in a native C++ DLL.
Here is my code:
The C# side:
[DllImport(@"Native3DHandler.dll", EntryPoint = "#22", CharSet = CharSet.Unicode)]
private static extern void func1(string str);
public void func2(...
My (C++, cross-platform) app is heavily using Boost libraries (say version 1.x), and I want to also link against a 3rd-party (vendor)'s SDK (no source), itself using Boost (but version 1.y).
So, we both link dynamically against our own version of Boost DLLs, CRT being identical. Consequently, at run-time my app would have to load both D...
int fn();
void whatever()
{
(void) fn();
}
Is there any reason for casting an unused return value to void, or am I right in thinking it's a complete waste of time?
Follow up:
Well that seems pretty comprehensive. I suppose it's better than commenting an unused return value since self documenting code is better than comments. P...
I'm writing a game and I'm wound up in needing a console for simple text input; filenames and simple values.
Using SDL, my console looks the following at it's simplest:
class Console
{
public:
typedef std::list<String> InputList;
enum Result
{
NOTHING = 0,
ENTERED,
ESCAPED
};
static const String& GetInput() { return...
Have a look at this code:
#include <iostream>
using namespace std;
int main()
{
const char* str0 = "Watchmen";
const char* str1 = "Watchmen";
char* str2 = "Watchmen";
char* str3 = "Watchmen";
cerr << static_cast<void*>( const_cast<char*>( str0 ) ) << endl;
cerr << static_cast<void*>( const_cast<char*>( str1 ) )...
I've a situation like this:
class MyClass
{
private:
std::auto_ptr<MyOtherClass> obj;
public:
MyClass()
{
obj = auto_ptr<MyOtherClass>(new MyOtherClass());
}
void reassignMyOtherClass()
{
// ... do funny stuff
MyOtherClass new_other_class = new MyOtherClass();
// Here, I want to:
// 1) Delete the point...
C++ code:
struct tPacket
{
WORD word1;
WORD word2;
BYTE byte1;
BYTE byte2;
BYTE array123[8];
}
static char data[8192] = {0};
...
some code to fill up the array
...
tPacket * packet = (tPacket *)data;
We can't do that as easy in C#.
Please note there is an array in the C++ structure.
Alternatively, using this sou...
I was curious what is the scope of variables declared inside a class constructor which are not data members of that class?
For example, if a constructor needs an iterating int i, will this variable be destroyed after the constructor finishes, or is it then global for the program?
Thanks!
...
I have a hierarchy of classes. The base class uses some tuning parameters that are loadable from file (and reloadable during runtime). Each derived class may add some additional parameters. I am looking for a way to allocate a correctly sized parameters array in the base constructor, so that I don't have to deallocate and reallocate ...
This is a rather basic question, but it's one that's bugged me for awhile.
My project has a bunch of .cpp (Implementation) and .hpp (Definition) files.
I find that as I add additional classes and more class inter-dependencies, I have to #include other header files. After a week or two, I end up with #include directives in lots of plac...
This issue is important especially for embedded development. Exception handling adds some footprint to generated binary output. On the other hand, without exceptions the errors need to be handled some other way, which requires additional code, which eventually also increases binary size.
I'm interested in your experiences, especially:
...
I have a class called ImageMatrix, which implements the C++ map in a recursive fashion; the end result is that I have a 3 dimensional array.
typedef uint32_t VUInt32;
typedef int32_t VInt32;
class ImageMatrix
{
public:
ImageMatrixRow operator[](VInt32 rowIndex)
private:
ImageMatrixRowMap rows;
};
typedef std::map <VUInt32, VIn...
Hi,
in the following piece of code, I see that when my 'description' is something like:
" ' ' ", I have a problem updating the description to the sqlite record.
How do i handle the ' character. thanks!
sql = wxString::Format(
"UPDATE event SET event_description='%s' WHERE id=%d",
description.c_str(),
event_id);
rc = sqlite3_...
Duplicate of this.
In C++ you sometimes have to implement the copy constructor yourself (when you have pointer as a member usually). Over compiler generated copy constructor this has the disadvantage that when you add a member field and forget to add the copying line in the copy constructor, you have a problem, which is often hard to tr...