How to use typedef in nesting class?


,please look at this code. /////////////////////////////////////////////////// #include using namespace std; class A{ private: class B;// public: int out(int x){ return outB(x)->a; } B * outB(int x); private: B* root; class B{ int a; B(int init_a) :a(init_a){} friend class A; ...
Posted On: Monday 26th of November 2012 12:48:48 AM Total Views:  278
View Complete with Replies

RELATED TOPICS OF C Language PROGRAMMING LANGUAGE




how to use functors as ordinary functions argument?

dear, all: below is a function with a parameter of function pointer. void f(int a, int b, int (*fp)(int, int)) { std::cout << fp(a, b) << std::endl; } and f is called with functor plus as 3rd argument. int x ...
VIEWS ON THIS POST

151

Posted on:

Sunday 25th November 2012
View Replies!

What do you use RAII for?

What kinds of things have you used Resource Acquisition is Initialization for I've been using it in a few places and its remarkably useful. Here is where I've use this currently: 1. Creating and/or maintaining hourglass cursors in and ...
VIEWS ON THIS POST

111

Posted on:

Sunday 25th November 2012
View Replies!

Re: boost::shared_ptr used in covariant return type

zade wrote: > boost::shared_ptr is good for return type when you create a new type > using pimpl idiom, but in practice, it gives me some trouble when used > for covariant return type. code like below: blah > so, ...
VIEWS ON THIS POST

157

Posted on:

Sunday 25th November 2012
View Replies!

use of template variables ?

#include template struct A { void f(){ switch(role) { case 0: case 1: printf("did match\n"); default: printf("did not match\n"); } } }; int main() { A<0> a; A<1> b; } This is a simplified representation of a C++ ...
VIEWS ON THIS POST

130

Posted on:

Sunday 25th November 2012
View Replies!

SDL_ttf bug causes segfault for weird reasons

I'm writing a small game, and I've been getting an almost pathetic bug with SDL. I've written a small wrapper (textutil.h:rtTextUtil) to make rendering easy. Now if i call it from a class defined in a header file (class.h:ClassGood), it ...
VIEWS ON THIS POST

162

Posted on:

Sunday 25th November 2012
View Replies!

Proper union use

I remember from C that you are not supposed to access different members of a union at the same time It seems to say the same thing in the C++ standard (9.5.1) "In a union, at most one of the ...
VIEWS ON THIS POST

128

Posted on:

Sunday 25th November 2012
View Replies!

How to use the iterator from base class in a derived class?

I am trying to write a class myVector based on std::vector and add only a sort method. The sort method needs to access the array stored in the base class using iterator. I have following draft code. However it never ...
VIEWS ON THIS POST

108

Posted on:

Sunday 25th November 2012
View Replies!

How to use function from dll file in C++ code?

I want to use netCDF library, and I have dll file without header file, I know what functions are in this lib, and how to use it, but how to compile project using this dll \t I use g++ compiler ...
VIEWS ON THIS POST

178

Posted on:

Sunday 25th November 2012
View Replies!

valid use of cast

I have the following: 1: template< class Sumtype, class Averagetype > 2: Averagetype Average( Sumtype* p_array, Averagetype p_count ) 3: { 4: int index; 5: Sumtype sum = 0; 6: for( index = 0; p_count > index; index++ ) 7: ...
VIEWS ON THIS POST

100

Posted on:

Sunday 25th November 2012
View Replies!

template question: preallocation for the underlying deque in user-defined queue

Heck wrote: > I borrowed N. Josuttis's code for a queue ("The C++ Standard Library", > 1999, p. 450), with which he modifies the interface to read and > discard the front element on pop() and to throw an exception ...
VIEWS ON THIS POST

179

Posted on:

Sunday 25th November 2012
View Replies!

When to use ::

I have often come across functions which start with :: but have never know exactly what this meant. Could someone please elucidate Cheers, David...
VIEWS ON THIS POST

147

Posted on:

Sunday 25th November 2012
View Replies!

template template par used for a container statistic

hi, a) what's wrong with this code it looks like allocator is the problem. the commented version works fine, but if possible i'd rather not limit myself to ublas::vector b) the version that works is slow compared to mathematica. is ...
VIEWS ON THIS POST

121

Posted on:

Sunday 25th November 2012
View Replies!

user defined conversion operator or operator overloading?

I have an host class that holds fundamental types template struct Generic{ Generic(T val= T()):mval(val){} operator T(){return mval T mval; } template Genericoperator+(const Generic& lhs,const Generic& rhs) { return Generic(lhs.mval+rhs.mval); } ...
VIEWS ON THIS POST

129

Posted on:

Sunday 25th November 2012
View Replies!

how to return 2 instances of the same user-defined class from a function

i have a class "myClass", and i want to return two instances of the same class from a function. I define an array as follows : "myClass sample[2] ;" and i initialize two instances: "myClass sample1, sample2 ;" "sample[0] ...
VIEWS ON THIS POST

117

Posted on:

Sunday 25th November 2012
View Replies!

Design Pattern Question: Why use Interfaces?

I am refactoring code. The original authors of my project performed a lot of cutting and pasting making it hell to maintain (because you have to fix the same bug in 16 different places) and it is my job to ...
VIEWS ON THIS POST

109

Posted on:

Monday 26th November 2012
View Replies!

linked links - have to use structs?

, I am very much still learning to use pointers and am now using them to implement some basic ADTs including linkedlists. I realize C++ standard includes a ton of goodies including a linkedlist template. I am attempting to implement ...
VIEWS ON THIS POST

120

Posted on:

Monday 26th November 2012
View Replies!

how to use the return value when using C# dlls in a C++ project?

hi, I am using a C# library in my C++ project. I want to make use of the classes defined in the library to do some job, and use the return value to go on other works in my project. ...
VIEWS ON THIS POST

155

Posted on:

Monday 26th November 2012
View Replies!

How to use objectiented programming.

I have been writing some large programs and games lately and I have had people advise me that I need to write more object oriented programs. I also I understand the concept and have written some small programs to understand ...
VIEWS ON THIS POST

124

Posted on:

Monday 26th November 2012
View Replies!

Can't use activex control inside Cdialog and thread

I would like to get use my activex control inside Cdialog in beginthreadex When I used Cdialog and activex control , everything is fine but when i put it inside thread (beginthreadex), it doesn't work anymore. I can use ...
VIEWS ON THIS POST

128

Posted on:

Monday 26th November 2012
View Replies!

Modifying temporary values: fundamental vs. user types

I recently noticed a subtlety in C++ rules, and I would like to understand the reason for it: this rule is the one saying that temporary values of fundamental types cannot be modified. At first sight, this makes perfect sense, ...
VIEWS ON THIS POST

129

Posted on:

Monday 26th November 2012
View Replies!