c++

C++ templates and inheritance

Hi, can I mix inheritance and templates this way ? : template <class T> class AbstractType { // abstract //.... } template <class T> class Type1 : public AbstractType<T> { //.... } And later on, can I use these classes like this: AbstractType<SomeClass>* var1 = new Type1<SomeClass>(); Thx for help. ...

Unqualified lookup and (maybe-)dependent base classes

Consider the following program: template <typename T> struct t { struct base { void f1(); }; struct derived : base { void f2() { f1(); } }; }; In derived::f2, unqualified lookup is used to find f1. Will base be searched? Will base::f1 be found? Is base a dependent type? Please subst...

Deleting object from a stack.

Is it bad/illegal C++ to delete manually objects from a stack or there are situation when it is acceptable? Edit Constructor(pointer parent, pointer left, pointer right):parent_(parent),left_(left), right_(right) { } ~Constructor() { delete parent_; delete left_; delete right_; } main()...

Using program as library that contains main function

I am planning to write a program that makes calls to cdrecord. (I am a beginner, a beginner trying to "scratch an itch") The program would be written in C++. I have identified that I need to be able to run cdrecord in order for this to work. cdrecord is written in C. However the documentation on using it is from the command line. The so...

declaring a pointer to a two dimension array of void*

I'm having trouble figuring out how to declare a pointer to an array of arrays of void*. (I can't use STL containers and the like because it's an embedded system.) I have some data that I'm trying to group together in a structure. Mostly built-in data types, but then are these two arrays. The first one, char *testpanel_desc[] = {...}; ...

What do the * and & operators operate on if the argument is complex?

Simply, is &someObject->someAttribute.someMember; equivalent to &(someObject->someAttribute.someMember); or (&someObject)->someAttribute.someMember; or (&(someObject->someAttribute)).someMember; Or should you really put explicit parenthesis there just to be safe? ...

Something like boost::multi_index for Python

Hi, I have come to appreciate a lot boost::multi_index in C++. It happens that I would happily use something like that in Python; for scripts that process data coming out from numerical intensive applications. Is there such a thing for Python? I just want to be sure that it doesn't exist, then I would try to implement it myself. Things ...

Looking for a good book covering CURL library under c++

Hello, are there any good books/tutorials decscribing how to use CURL library under C++ to implement FTP / SFTP clients ? Thx for help. ...

reading char by char

my question is a little bit strange, but how is it possible to read some string from keyboard char by char without using scanf() and getchar() only by using operator<<, for example I want to change every letter a which I read by * thanks in advance ...

Return Array from Class

Hello there, I need to return 3 values. X, Y, Z. I've tried something like this, but it does not work, can anyone help me a bit? I've looked here: http://stackoverflow.com/questions/2334280/return-a-float-array-in-c and I tried to do same thing, except with 1 dimensional array to return. class Calculate { float myArray[3][4], originalA...

VS2010 C++ does not include paths to .pdb is my compiled .dlls according to dumpbin.

Visual Studio compiles the projects into dlls as I want it to, but when I inspect these dlls with dumpbin, then they do not have an entry for their pdbs, which is probably the reason why I cannot debug any of those dlls if I load them at runtime and their pdbs are never loaded. How can I get VS to write these paths? Visual Studio, C++. ...

sort names by their age

i want so sort names by their ages #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; struct Person{ std::string name; int age; }; struct by_age{ bool operator() (Person const &a,Person const &b){ return a.age>b.age; } }; int main(){ vector<Person>people; for (int i=0;i...

Experienced C++ trying C#

Would you hire an experienced C++ programmer to do a C# project? ...

Getting started with a cross platform C++ project

I am starting a c++ project which I would like to compile equally well in Eclipse (Linux) and vs2010 from the same repository and could use some help getting started. While many of the aspects can individually be Google'd, I was hoping for advice on how to approach the problem on a whole. For example, where to keep the library sources,...

Reusing interfaces throughout your application

I am currently busy refactoring big parts in my application. The main purpose is to remove as much as possible dependencies between the different modules. I now stumble on the following problem: In my application I have a GUI module that has defined an interface IDataProvider. The interface needs to be implemented by the application ...

null terminator problem while comparing identical char*

i try to compare between 2 char* identical strings,but one of them contains a null terminator at the end. i've been looking through the internet and understood that it's not recommendable to remove the null terminator char cause it will make the string unstable. what other methods can i use? the comparing function: int StringCompare(co...

destroying a singleton object

What is the best way to destroy a singleton object? case A: Single threaded Environment case B: Multi Threaded Environment Sample snippets(if any) will be really helpful. [EDIT] I don't have a specific use case I am just trying to understand that IF AT ALL the singleton has to be used how to destroy it correctly. As i understand...

Combining C++ and C - how does #ifdef __cplusplus work?

I'm working on a project that has a lot of legacy C code. We've started writing in C++, with the intent to eventually convert the legacy code, as well. I'm a little confused about how the C and C++ interact. I understand that by wrapping the C code with extern "C" the C++ compiler will not mangle the C code's names, but I'm not entire...

C++ std::vector erasing element 0 throws exceptions

Sorry I can't provide code bc I don't have it. My coworker (who has been with the company for a long time but doesn't appear to know what he's doing) claims that he has to do some weird stuff to remove elements from a vector. He moves all the elements down a position (starting at the element that he wants to remove) then he'll remove t...

invalid cast to type 'float'

I'm having problem with my class. I'm going to make comparision operators of my class. Some code: CVariable::operator float () { float rt = 0; std::istringstream Ss (m_value); Ss >> rt; return rt; }; bool CVariable::operator < (const CVariable& other) { if (m_type == STRING || other.Type() == STRING) int i =...