Doubt regarding operators in C/C++/Java
Consider the follwoing fragment: int a,b; a = 1; b = 2; c = a++++b; // does not work!! Compilation error. c = a++*+b; // works !! Please help me understand this behaviour. ...
Consider the follwoing fragment: int a,b; a = 1; b = 2; c = a++++b; // does not work!! Compilation error. c = a++*+b; // works !! Please help me understand this behaviour. ...
Hay Dear! First of all have a look at the following code (in this code shape is the base class and line is the derived class) void drawshapes(shape sarray[],int size) { for(int i=0;i< size; i++) sarray[i].draw(); } main() { line larray[10]; larray[0]=line(p1,p2);//assuming that we have a point class larray[1]=line(p2,p...
Given a linked list of T size , select first 2n nodes and delete first n nodes from them; Then do it for the next 2n nodes and so on... For example- Let's consider a linked list of size 7: `1->2->3->4->5->6->7` If n = 2, the desired output is : `1->2->5->6->7` I didn't understand what this problem is actually indicating.Could...
Is the following legal C++ code: class C { static public int x; }; It compiles OK in Visual Studio 2008 C++ and Visual Studio 2010 C++ (beta 2). But the static member x does not end up being public. In Visual Studio 2010 beta 2 the experience is even stranger. Intellisense reports an error "expected an identifier", but the co...
Ok, I've been sitting in front of profiler results over the last three days, generated by running a pretty wide range of test cases through an automation suite. The idea is to see if there are any good optimisations that can generally improve performance. I'll qualify good in this context as follows; Has the potential for performance...
For those who are following the saga, I am still trying to define Finite State Machine, states & events in the "proper" C++ way, with templates. What's wrong with this code? template <typename StateTypeEnum, typename EventTypeEnum> class Fsm { public: Fsm(E_subSystems subSystem, uint8_t instance, const char * cons...
Can I mix extern and const, as extern const? If yes, does the const qualifier impose it's reign only within the scope it's declared in or should it exactly match the declaration of the translational unit it's declared in? I.e. can I declare say extern const int i; even when the actual i is not a const and vice versa? ...
Hello! I am desparately searching for place several graphics having a transparent background on the same background with GDI+. I did not have any programming experience with Windows or graphic programming (like games) before, so it is more difficult to find a solution. GDI+ has a transparent colour. GDI+ only uses the transparency infor...
I need to implement a simple ATL COM object that implements a specific interface for which I have been given both a .tlb file and a .idl file. The interface is very simple and only consists of a single method. I have created many ATL objects in the past but never one that has to implement a specific interface. What do I need to achiev...
I got into a problem with my classes, passing a const object (polymorphic structure) to an explicit constructor which takes a const reference to the base class of that polymorphic structure. Here is the sample (this is not from my code, it is for explanation here) class Base { ... } class Derived:public Base { ... } class Problem { ...
Hello Everybody, I have a couple of questions about XML. Can XML be used for normal c++ application instead of using a text file ? If so, does this method have advantages? and finally, how can I use XML to store data? what tools are needed? Regards. ...
Hi, all! I have an array of data that represents PNG: unsigned short systemFontTexture[] = { ... 0x5089,0x474E,0x0A0D,0x5089,0x474E,0x0A0D,0x5089, 0x474E,0x0A0D,0x5089,0x474E,0x474E,0x0A0D,0x5089, 0x474E,0x0A0D,0x5089,0x474E,0x474E,0x0A0D,0x5089, ... } Can I create PNG file using this data? If yes, then HOW? ...
How do I do that? Like you know in Java, you can use an ArrayList and it will take any object as long as you cast it down to whatever it is when you're retrieving the object. Even better, you can specify what class of objects that ArrayList would store by doing... new ArrayList()< whateverObject > I've implemented a linked list da...
Hi, I am getting an error with this code. 'Incompatible types in assignment of char to char[13]' I can't figure out how to initialize these arrays and make this work. Basically, the program takes ISBN codes (4 groups of integers and makes one string with '-' in them between each group of numbers) and verifies that they are correct. The p...
I've a custom container which is implemented in two different ways, but with a single interface. some thing like this. class Vector { virtual Iterator begin() = 0; virtual Iterator end () = 0 ; ... // some more functions. } ; class VectorImplA : public Vector { Iterator begin() { return m_...
Hi I thought of a small debug inline function in C++: void inline debug( int debug_level, ostream& out ) { if ( debug_level <= verbosity ) { out.flush(); } else { ostream tmp; tmp << out; } } This is an example of how I wanted to use it: _debug( 7, cout << "Something something" << someint << e...
I have a large cross-platform (Linux and Windows) C++ project, for which I want to create a GUI. I have few very general questions about the basic principles of GUI for such project: Should the GUI be separated from the application's logic? If it is separated, how should the logic and the GUI communicate? Are TCP/IP sockets a good opt...
I basically want to have a base container class which can return a generic iterator that can be used to traverse an instance of the container class, without needing to specify iterator templates. I think I cannot implement the base container over a class template, which would then require a traversal algorithm based on template classes w...
Do structures support inheritance? I think it's stupid question, but I have not much idea about it. What is the meaning of writing code like this: struct A { void f() { cout << "Class A" << endl; } }; struct B: A { void f() { cout << "Class B" << endl; } }; In structures also private section will come, don't they give encapsul...
I have a map like this: map<prmNode,vector<prmEdge>,prmNodeComparator> nodo2archi; When I have to update the value (vector), I take the key and his value, I update the vector of values, I erase the old key and value then I insert the key and the new vector. The code is this: bool prmPlanner::insert_edgemap(int from,int to) { prmEd...