The point of pointers
I Know am very wrong about this, but i would like some help. What is the point of pointers in c++ when i can just declare variables. What, When, Where is a good situation to use them? ...
I Know am very wrong about this, but i would like some help. What is the point of pointers in c++ when i can just declare variables. What, When, Where is a good situation to use them? ...
I followed the model/view/controller paradigm. I am pretty sure that the model and view are right, but I think I'm doing some things wrong in my delegate. Everything "works", except the first click to a control just "lights up the control" and the second one interacts with it. Is this how delegates are usually implemented? My impleme...
I have three classes: A data holder class CDataHolder, which uses a Pimpl pattern class CDataHolder { public: // ... private: friend class CBase; struct PImpl; PImpl* iPimpl; }; A base class CBase, which need to access the iPImpl member in CDataHolder, so it is a friend class of CDataHolder class CBase: { protected: CDataHolde...
I am writing some C++ code in Linux where I have declared a few 2D arrays like so: double x[5000][500], y[5000][500], z[5000][500]; During compilation there is no error. When I execute it says "segmentation fault". Wen I reduce the size of the array from 5000 to 50, the program runs fine. How can I protect myself against this proble...
I am working on a project which talks to SQL server and most of the back end code is in C++. This is an application which controls flow of few fluids while loading them into carriers. Some of the back end modules which talk to controllers which in turn control flow of fluids are in C++. Since they have memory leaks and some other bugs, t...
i am trying to write a memcpy function that does not load the source memory to the cpu cache. The purpose is to avoid cache pollution. The memcpy function below works, but pollutes the cache like the standard memcpy does. i am using P8700 proccesoor with visual C++ 2008 express. i see the cpu cache usage with intel vtune. void memcpy(c...
I want to check that whether the system is in log off state or not in VC++, any ideas? ...
Hi, everyone. This is my very first question in SO. I've been working for years with Java. During those years, I've made extensive (or maybe just frequent) use of Reflection, and found it useful and enjoyable. But 8 months ago I changed my job, and now Java is just a memory, and I'm getting my hands on C++. So now I'm wondering if there...
Hi, This looks like homework stuff but please be assured that it isn't homework. Just an exercise in the book we use in our c++ course, I'm trying to read ahead on pointers.. The exercise in the book tells me to split a sentence into tokens and then convert each of them into pig latin then display them.. pig latin here is basically ...
I have a relatively simple question. Say I have a file but I only want to access line X of the file until line Y, whats the easiest way of doing that? I know I can read in the lines one by one keeping count, until I reach the lines that I actually need, but is there a better more elegant solution? Thanks. ...
Hi all, Yesterday I ran into a g++ (3.4.6) compiler problem for code that I have been compiling without a problem using the Intel (9.0) compiler. Here's a code snippet that shows what happened: template<typename A, typename B> class Foo { }; struct Bar { void method ( Foo<int,int> const& stuff = Foo<int,int>() ); }; The g++ compi...
I have a C++ app that uses standard socket calls and I want to know if I can tell if a socket is still open without sending or receiving any data. Is there a reliable select or ioctlsocket call I can make? ...
Why does this code fail to compile with VS 2005: #include <boost/bind.hpp> #include <boost/function.hpp> struct X { typedef std::auto_ptr<int> IntType; // typedef int IntType; // this works IntType memfunc () const { return IntType (); } X () { boost::bind (&X::memfunc, this); } }; wi...
What resources would you recommend on the subject? What I am looking for is practical advice on the differences of different approaches (MVC, MVP, Presenter First, Humble Dialog), their implementation details (setting it up, passing messages around, connecting) and unit / automated integration testing approaches. My main interest would b...
I was reading here and there about llvm that can be used to ease the pain of cross platform compilations in c++ , i was trying to read the documents but i didn't understand how can i use it in real life development problems can someone please explain me in simple words how can i use it ? ...
Hi, as i understand that any .NET program gets compiled to MSIL which is fed to the CLR which compiles it to the assembly code and along with the help of JIT it executes it. I was wondering, as .NET is a wrapper around the win32 api and the CLR ultimately converts the MSIL to assembly program. Isn't it possible for me to write some func...
Hi, If I declare a global variable in a header file and include it in two .cpp files, the linker gives an error saying the symbol is multiply defined. My question is, why does this happen for only certain types of object (eg. int) and not others (eg. enum)? The test code I used is given below: test.h #ifndef TEST_HEADER #define TEST_H...
GIVEN that you have a fixed area of memory already allocated that you would like to use, what C or C++ libraries will allow you to store a dynamic structure (e.g. a hash) in that memory? i.e. the hash library must not contain any calls to malloc or new, but must take a parameter that tells it the location and size of the memory it is pe...
Ive got an application which drops to around 10fps. I profiled it with xperf which showed my app was using just 20% of the CPU, with none of my methods using a larger than expected amount of that 20%. This seems to indicate that the vast drop in fps is because the graphics card isnt able to keep up with rendering the frame, resulting in...
I am sending and receiving binary data to/from a device in packets (64 byte). The data has a specific format, parts of which vary with different request / response. Now I am designing an interpreter for the received data. Simply reading the data by positions is OK, but doesn't look that cool when I have a dozen different response forma...