c++

How to generate half-edge structure representation for a polygonal mesh?

I would like to generate output to display the numeric data of the Half-Edge Structure that is based from an input of polygonal mesh data (in numeric data form). The concept to read the polygonal model basically is like this: For the INPUT, the file is in OFF format and include datas like (a) First part: the number of vertex, number o...

Copying contents of one file to another in C++

I am using the following program to try to copy the contents of a file, src, to another, dest, in C++. The simplified code is given below: #include <fstream> using namespace std; int main() { fstream src("c:\\tplat\test\\secClassMf19.txt", fstream::binary); ofstream dest("c:\\tplat\\test\\mf19b.txt", fstream::trunc|fstream::binary);...

OpenGl surface&texture

I have: 3d pointset, wich calculated from 3d reconstruction process from N frame. sample frame snapthot (for example first frame when camera in (0,0,0)) 3d to 2d corresponds I want: create triangulation of point set and put texture (frame snaphot) on it. How can i create this triangulation + texture via OpenGL? I can't find any g...

Constructors cannot be virtual, why? Not a dupe

Possible Duplicate: Why do we not have a virtual constructor? I know this has been asked before but I didn't understand the complex technical words used in the other answers. I read on a community the reason that constructors cannot be virtual is The ‘virtual’ mechanism works on a logically complete (completely constructe...

Cuda Runtime API and driver API questions

I am new to cuda and graphics. I had several questions about cuda, hope someone will have proper answers: These are for driver API: -- What is the meaning of a cuda context? when i was reading cuda c book (3.1) i've learned that it is analogous to a process in CPU. I don't understand this, the actual host c code becomes a process in cp...

What's wrong with my program for "Write a program to count how many times each distinct word appears in its input using C++."

// Write a program to count how many times each distinct word appears in its input. #include <iostream> #include <string> #include <vector> int main() { // Ask for // and read the input words std::cout << "Please input your words: " << std::endl; std::vector<std::string> word_input; std::string word;...

how to get the first 5 elements from an queue c++

hello, how can i get the first five elements form an queue with out using for loop .... ...

Call a base class constructor later (not in the initializer list) in C++

I'm inheriting a class and I would like to call one of its constructors. However, I have to process some stuff (that doesn't require anything of the base class) before calling it. Is there any way I can just call it later instead of calling it on the initializer list? I believe this can be done in Java and C# but I'm not sure about C++. ...

Doubt in C++ with respect to objective C

I can write a function this way in objective C. This can be used to churn out many UIButtons. +(UIButton*)getButton:(CGRect)frame{ UIButton *button=[UIButton buttonWithType:UIButtonTypeRoundedRect]; [button setTitle:@"Some title" forState:UIControlStateNormal]; button.frame=frame; return button; } Can the same be done in C++. I a...

What's the cleanest way to defeat C++ access qualification?

I decided to work around a bug in GNU libstdc++ by accessing an internal variable. Recalling that Johannes solved the problem on his blog, I checked that out… but couldn't comprehend the code, aside from the basic concept of getting a static initializer to do the dirty work. So, I boiled it down to this, which is pretty compact. But, as...

NULL check before deleting an object?

This came up as one of the code review comments. Is it a good idea to check for NULL before calling delete for any object? I do understand delete operator checks for NULL internally and is redundant but the argument put forth was delete as an operator can be overloaded and if the overloaded version doesnt check for the NULL it may cra...

Lotus C++ API toolkit code crashes on "delete LNNoteArray" on windows server 2008 R2 64 bit

I upgraded our OS to Windows server 2008 R2 64 bit recently. I was using C/C++ API toolkit 8.0 version (with Lotus Notes client 8.5). All the sample exe's (32 bit version) ran fine on that machine in emulation mode. For one sample code i made some changes, i.e instead of doing - LNNoteArray SearchSet I did - LNNoteArray* pSearchSet = ...

How to break with GDB at object destruction if there is no destructor?

How to break with GDB at object destruction if there is no destructor? ...

Boost Intrusive List hook

What is the difference in a base hook and a member hook in Boost::Intrusive library and when is one better to use then the other? I've read the boost documentation, but its not that explanatory. ...

is there a browser object/class for g++?

I am looking for a browser class that can be created in a terminal program in g++ that will create a page in memory and execute client JavaScript. environment is Linux, server is h ubuntu 10.04 there is no GUI installed, program would be an occasional cron script. is there such an animal? edit: removed vbscript ...

What is wrong with using a static member object with a class?

I have heard that using static member objects is not a very good practice. Say for example, I have this code: class Foo { ... static MyString str; }; I define and initialize this variable in the implementation file of this class as: MyString Foo::str = "Some String"; // This is fine as my string API handles this. When I run this c...

Testing with boost

Can someone write step by step what to do to start using testing facilities from boost? For example I have a class: class A { public: int multiplyByTwo(const int input) { return input * 2; } }; and I would like to set test cases for multiplyByTwo fnc. How? In which files? What steps do I need to perform in order to run it? ...

Why is "operator delete" invoked when I call "delete" on a null pointer?

While reading answers to this question I noticed that answers (this for example) imply that operator delete can be called even when delete statement is executed on a null pointer. So I wrote a small snippet: class Test { public: void* operator new( size_t ) { /*doesn't matter*/ return 0; } void operator delete( void* ptr ) { ...

Waiting for Variable Change

Here my code snippet written in Qt. bool myFunc() { ....... while(!tcpCommunicator->isLoginReplyExist) { qApp->processEvents(QEventLoop::AllEvents); } ....... return tcpCommunicator->res; } After "isLoginReplyExist" is changed by another part of program I want to exit from loop, is there any better way to ...

managed system.timer over un managed code

New to the groups, sorry if this the wrong forum/etiquette. I am coding a c++ application that requires the use of a timer-triggered event handler. I decided to use the timer provided in System::Timers::Timer. My understanding of the next part is not very good, as my code may reveal, but as I understand it, my application is "unmanaged C...