sizeof a union in C/C++
What is the sizeof the union in C/C++? Is it the sizeof the largest datatype inside it? If so, how does the compiler calculate how to move the stack pointer if one of the smaller datatype of the union is active? ...
What is the sizeof the union in C/C++? Is it the sizeof the largest datatype inside it? If so, how does the compiler calculate how to move the stack pointer if one of the smaller datatype of the union is active? ...
Consider the following snippet: struct ObjectInterface { virtual ~ObjectInterface() {} virtual void Print(std::ostream& target) const = 0; }; struct Foo : ObjectInterface { virtual void Print(std::ostream& target) const { target << "Foo"; } }; struct Bar : ObjectInterface { virtual void Print(std::ostre...
i am trying to send ---.hex file to my siemens C55 throught serial port but while doing do i am getting an error "make.exe" program avrdude -p atmega8 -P com2 -c stk200 -U flash:w:gsm_remote.hex avrdude: port name "com2" is neither lpt1/2/3 nor valid number avrdude: can't open device "com2" avrdude: failed to open paral...
I've been using Emacs for quite some time for basic text editing but as of today I am attempting to use it for c++ compilation. I have looked for the past few hours about how to go about this but I keep hitting roadblocks in their techniques (I think some of this is having to do with the tutorials being outdated). Basically, all I want ...
Duplicate What are the differences between Generics in C# and Java… and Templates in C++? Hi all, I am experienced C++ programmer but quite new to C#. Whats up with those constraints and generics? Why doesn't it work the same as in C++ where constraints are implicit and derived from the instantiations you do to the template cla...
I have a small template class of type Locker contained within a boost::intrusive_ptr that I want to store inside a std::map: template <typename T> bool LockerManager<T>:: AddData(const std::string& id, T* pData) { boost::intrusive_ptr<Locker<T> > lPtr(Locker<T>(pData)); // Line 359 - compiles mMap.insert(make_pair(id, lPtr)); /...
Can someone point out a good mapping between the usual C++ STL containers such as vector, list, map, set, multimap... and the C# generic containers? I'm used to the former ones and somehow I've accustomed myself to express algorithms in terms of those containers. I'm having some hard time finding the C# equivalent to those. Thank you! ...
I know there are many IDE related questions already answered on StackOverflow, but I have a strange request. I'm looking for a C++ IDE for Windows that is designed with Linux as a destination compile point. I just want to use it for syntax highlight, code completion, basic error detection, etc. In the end all code will be sftped over ...
I'm trying to store a pointer in an array. My pointer to a pointer is class object is: classType **ClassObject; So i know i can allocate it by using the new operator like this: ClassObject = new *classType[ 100 ] = {}; I'm reading a text file, with punctuation and here is what i have so far: // included libraries // main function...
Hello all :) I am writing a piece of code designed to do some data compression on CLSID structures. I'm storing them as a compressed stream of 128 bit integers. However, the code in question has to be able to place invalid CLSIDs into the stream. In order to do this, I have left them as one big string. On disk, it would look something l...
I have a program that uses time() and localtime() to set an internal clock, but this needs to be changed so that the internal clock is independent of the user and the "real" time. I need to be able to set any reasonable starting time, and have it count forward depending on a timer internal to the program. Any ideas on the best way to a...
How would one programmaticly determine the version of windows currently installed? As in differentiate between vista and xp. ...
Hello :) I'm writing a compressor for a long stream of 128 bit numbers. I would like to store the numbers as differences -- storing only the difference between the numbers rather than the numbers themselves because I can pack the differences in fewer bytes because they are smaller. However, for compression then I need to subtract these...
Hi, I need to call my public member. The Constructor that takes 1 paramater. This is how my code looks: // main char tmpArray[100] = {}; while ( !inFile.eof() ) { for ( unsigned x = 0; x < str2.length(); x++ ) { if ( !isspace( str2[x] ) || isspace( str2[x] ) ) { tmpArray[x] = str2[x]; // prepare to supply the c...
I have a QTableView in the main UI of my program. I'd like to show popup menu when user right clicks on the cells of the table and take appropriate action when an option is selected from the menu. I am using Qt Creator 1 (Qt version 4.5). How can I do that? Thanks for your time. ...
Hello! I'm getting this error when dealing with a number of classes including each other: error: expected class-name before '{' token I see what is going on, but I do not know how to properly correct it. Here is an abstracted version of the code: A.h #ifndef A_H_ #define A_H_ #include "K.h" class A { public: A(); }; #...
What if I have this: union{ vector<int> intVec ; vector<float> floatVec ; vector<double> doubleVec ; } ; Of course, I'll be using just one of the 3 vectors. But... what happens when all the 3 vectors are contructed?? Would the consructors of the 3 vectors interfere with each other?? (since the 3 of them are in the same mem...
When using a container class like vector, list, etc., I can use the type of the elements by writing vector<type>::value_type. However, the following code template<class container> void foo(container elementtype b; } fails with the error "expected initializer before ‘elementtype’". Is it possible to infer the element type when th...
I'm just getting started with APR and it seems that there are two supported versions developed side-by-side: http://apr.apache.org/ The docs don't explain the difference between 1.3.x and 0.9.x... Can anyone please shed light on the matter? Or in short, which should I use? ...
We develop a network library that uses TCP and UDP sockets. This DLL is used by a testclient, which is started multiple times at the same PC for a load test. In Windows Vista, it is no problem to start the testclient many times. In Windows XP, starting it up to 5 times is no problem, but if we start it 6 times or more, and then closing ...