C++ Virtual/Pure Virtual Explained
I'm a little familiar with C++, but the virtual keyword still confuses me. What exactly does it mean? If a function is defined as virtual, is that the same as pure virtual? ...
I'm a little familiar with C++, but the virtual keyword still confuses me. What exactly does it mean? If a function is defined as virtual, is that the same as pure virtual? ...
I've heard so much about buffer overflows and believe I understand the problem but I still don't see an example of say char buffer[16]; //code that will over write that buffer and launch notepad.exe ...
Hello Stackoverflow, I'm currently using GCC 4.4, and I'm having quite the headache casting between void * and a pointer to member function. I'm trying to write an easy-to-use library for binding C++ objects to a Lua interpreter, like so: LuaObject<Foo> lobj = registerObject(L, "foo", fooObject); lobj.addField(L, "bar", &Foo::bar); ...
I am writing a function to process an incoming 32-bit buffer, representing changing data when it is compared to an corresponding stored 32-bit buffer. The position of the changing bit represents a number (i.e. a value of 8 means bit 3) that needs to be processed, along with whether the change is 0->1, or 1->0. Here is the current impleme...
Hello Everyone ! I have the following pair of functions: void RegisterSink( ISink & Sink ) void UnregisterSink( ISink & Sink ) Where ISink is an abstract base class. Internally, I would like to store pointers to the sinks in an std::set. When a sink is unregistered, i simply search for the pointer in my set, and remove it. My questio...
I am a first year Comp. Sci. student and am looking for the best way to develop C++ on a Mac. I have Xcode and Textmate. What are the benefits/negatives of each? Are there any better ones? I am not a fan of having to use a whole project to run programs with Xcode. Is this the only way to do it, or am I mistaken? Also, is there a way t...
I've looked at the standard and didn't see an obvious answer. suppose i've done this: std::istream_iterator<char> is(file); while(is != std::istream_iterator<char>()) { ++is; } now is is at the end of the stream and is equal to std::istream_iterator<char>(). What happens if I increment it one more time? Is it still equal to std::...
Consider this simple example: template <class Type> class smartref { public: smartref() : data(new Type) { } operator Type&(){ return *data; } private: Type* data; }; class person { public: void think() { std::cout << "I am thinking"; } }; int main() { smartref<person> p; p.think(); // why does not the compiler...
I keep receiving a C2664 conversion error in visual studio It tells me that it can't convert parameter 1 from const std::string to std::string&. I tried adding/removing the const in the stringToWstring prototype and in the function itself and the error still comes up. wstring hexval = buff.substr(buff.find(L"hex(2):")); wstrin...
I am currently intern at telecominication company which is major one and also undergraduate student.I have lots of options sitting front.By know i know c,c++,c#,java languages on stand alone application side,on mobile side i trying to get into android world and also know php,mysql,asp.net and also java ee,spring on web side.But i really ...
Hi, Is there anyway to analyze the audio pitches programmatically. For example, i know most of the players show a graph or bar & if the songs pitch is high @ time t, the bar goes up at time t .. something like this. Is there any utility/tool/API to determine songs pitch so that we interpolate that to a bar which goes up & down. Thanks...
So I use Qt a lot with my development and love it. The usual design pattern with Qt objects is to allocate them using new. Pretty much all of the examples (especially code generated by the Qt designer) do absolutely no checking for the std::bad_alloc exception. Since the objects allocated (usually widgets and such) are small this is har...
Hi, Until now I thought that a Main Panic 42 occurs only when I try to access data that is outside of boundaries of an array for instance. Thanks to some nice feedback of you guys I was able to solve me other problem. However, what happens now is that I get this Panic when trying to allocate a char array as follows unsigned char *buf =...
I have a project that runs perfectly well under windows 7, x86 installation. On the same machine, but in a different drive, I've installed windows 7, x64, and visual studio 2008 sp1 on both. The project compiles and runs under win32. When I try to compile the project under x64, I get nothing, and everything gets 'skipped'. Furthermor...
I am currently working on a Cygwin/GCC application written in C++. The application requires embedding of python to run plug-ins, I've successfully embedded using the Cygwin python libraries and was able to run simple python files as part of the program. However, the python files now require the use of a windows GUI framework (wxPython), ...
I have class Fred { public: void inspect() const {}; void modify(){}; }; int main() { const Fred x = Fred(); Fred* p1; const Fred** q1 = reinterpret_cast<const Fred**>(&p1); *q1 = &x; p1->inspect(); p1->modify(); } How would it be possible to do the const Fred** q1 = &p1 via pointer-casting? (I have just been reading...
Hi, The CreateFileMapping function returns a pointer to a memory mapped file, and I want to treat that memory mapping as an array. Here's what I basically want to do: char Array[] = (char*) CreateFileMapping(...); Except apparently I can't simply wave my arms and declare that a pointer is now an array. Do you guys have any idea how...
I'm trying to read binary data from a specific offset. I write the data in the following way: long RecordIO::writeRecord(Data *record) { this->openWrite(); fstream::pos_type offset = file->tellp(); file->write(reinterpret_cast<char*>(record), sizeof(Data)); return (long)offset; } The offset returned is stored, and re...
I've been playing with this and I can't understand why the RegDeleteKey function is resulting to a file not found error.. I created this test key and it exists. HKLM\Software\test I am also the administrator of this computer. OS is Vista 32 bit. int main() { HKEY hReg; LONG oresult; LONG dresult; oresult = RegOpenKeyE...
I have a CListCtrl with plenty of room for all of the items, and they all display correctly --- until selected! As soon as any entry is selected, the end of that entry is truncated and an ellipsis is added: Click for Image I have no idea why this is happening. You can't see it in this image, but even very short entries show this beha...