c++

Javascript code working in the html file not working when taken as a string in C++

I have html file with javascript code the contents of the file are as under: I tried this code on Safari and it was working fine. But when I tried this on Firefox, it’s not working. Can any one suggest how to make it working on firefox. <html><head></head><body><button type="button" onClick="handleButtonClick();">undo</button> <button...

how to template for operator<< for ostream

The following won't compile for me. I'm out of ideas... Any help? template<> inline std::ostream& operator<< <const std::map<std::string, std::string> > (std::ostream& stream, const std::map<std::string, std::string>& some_map) { return stream; } g++ gives me the following error: error: expected initializer before '<' token Edit: ...

"Interface" like semantics with boost::bind

I wanted to be able to have something like Java's interface semantics with C++. At first, I had used boost::signal to callback explicitly registered member functions for a given event. This worked really well. But then I decided that some pools of function callbacks were related and it made sense to abstract them and register for al...

How do I make a C++ console program exit?

Is there a line of code that will terminate the program? Something like python's sys.exit()? ...

Superscript in C++ console output

I'd like to have my program output "cm2" (cm squared). How do make a superscript 2? ...

C++ DLL causes error when specific method called from .NET wrapper

I have this C++ dll where i created a wrapper with PInvoker. This small app is working great on my development pc with windows 7 64 bit. But soon as i try to work the release on a xp machine and when a specific action is happening it throws an error that the device is not ready. The dll is managing a serial device, where in all other act...

Questions about const and ifdef

Possible Duplicates: the role of #ifdef and #ifndef How many and which are the uses of const in C++? I am new to this field and I am just not getting certain functions or concepts. For example, I have this code: #ifdef directory Now, we could use a simple if condition in the program. So why is #ifdef used? I don't get ...

DevCPP / VS windows app header problem (noob)

I'm working through theForger's win32 tutorial, on two IDEs: Dev C++ and Visual Studio 2008. I try to duplicate results in both. For this page of the tutorial, I can't seem to compile in Dev C++ (Visual Studio works fine). It's a modal dialog box. The code in question is in WndProc: case ID_HELP_ABOUT: int ret = DialogBox(GetModul...

How can I remove the function call ambiguity from a Lemon grammar?

I have the following lemon grammar (simplified from the real grammar): %right ASSIGN . %nonassoc FN_CALL . program ::= expression . expression ::= expression ASSIGN expression . expression ::= function_call . [FN_CALL] expression ::= IDENTIFIER . function_call ::= expression LPAREN RPAREN . [FN_CALL] I'm not able to fix the shift-r...

Specifying multiple build rules/tools per input file in a VS2008 project

Hi, I have a pre-processor that I'd like to run on my .cpp/.h files before compiling them. I created a Custom Build Rule and applied it to my project. This successfully runs the pre-processor, but it does not actually compile the files afterwards. So what I'd like to do is run my custom rule first and then run the C/C++ Compiler Tool...

using a simple assert() macro

I'm new to programming & i found this code when i was going through a book. I believe it gives an example of how to use a defined assert() macro. It doesn't compile on code::blocks 10.05. I get errors such as '#' is not followed by a macro parameter unterminated #else in function 'int main()' 'ASSERT' was not declared in this scope C...

classes inside a class by template

we make a class with data member and its methods.. now my question is that can we make a classes inside a class.. i think we can get it by using template.. like template <class T> class class_template_list { public: class class_link { public: T item; class_link* prev; class_link* next; class_link(const T& value) { prev...

Checking if two cubic Bézier curves intersect

Hello guys, For a personal project, I'd need to find out if two cubic Bézier curves intersect. I don't need to know where: I just need to know if they do. However, I'd need to do it fast. I've been scavenging the place and I found several resources. Mostly, there's this question here that had a promising answer. So after I figured wha...

wxPython and StaticBox(Sizer) issue

Recently I've been having an issue with the code shown below and it's been bugging me for a while now. I don't know why it's happening, the only thing I know is that the python code brings up a segfault on the line noted and gdb brings up something about memory. Am I doing something wrong or is this a bug? I'd really like to get this wor...

x86 MUL Instruction from VS 2008/2010

Will modern (2008/2010) incantations of Visual Studio or Visual C++ Express produce x86 MUL instructions (unsigned multiply) in the compiled code? I cannot seem to find or contrive an example where they appear in compiled code, even when using unsigned types. If VS does not compile using MUL, is there a rationale why? ...

windows win32 GUI question.

Hello i am trying to use stream videos from a camera on a win32 window. from the camera APi, there is a function to set where the video is going to put SetVideoPosition(int xpos, int ypos, int xsize, int ysize, int left_clip, int top_clip, int right_clip) xpos, ypos: x and y coordinates of the top left corner. xsize, ysize horizon...

problem about pointer

GValue GmBase::getDistancePL(const lPoint& pt, const char* line) { int i, curr=0; InfoType ptcnt; GValue d, dist = KDBL_MAX; lPoint *p; ptcnt = *(InfoType*)line; p = (lPoint*)&line[InfoSize]; for( i=1; i<ptcnt; i++ ) { d = getDistance( pt, p[i-1], p[i] ); if( d < dist ) dist = d; } ...

friend declaration declares a non-template function

I have a base Class akin to the code below. I'm attempting to overload << to use with cout. However, g++ is saying: base.h:24: warning: friend declaration ‘std::ostream& operator<<(std::ostream&, Base<T>*)’ declares a non-template function base.h:24: warning: (if this is not what you intended, make sure the function template has alread...

How can I substring a TCHAR

I have a TCHAR and value as below: TCHAR szDestPathRoot[MAX_PATH]="String This"; Now I want the 1st three character from TCHAR , like below: szDestPathRoot.substring(0,2); How can I do this. ...

Prepending a string to a logger on function entrance...

Hi, I have a logger class. Call it MyLogger. I may use it in a function like this: void MyFunc(MyLogger& oLogger) { //Do stuff oLogger.Log("In MyFunc : Some Error"); //Do something else oLogger.Log("In MyFunc : Some other error"); } Now, I want to prepend "In MyFunc" to the logs if the log comes from inside MyFunc. Simi...