comp.lang.c++
  Home FAQ Contact Sign in
comp.lang.c++ only
 
Advanced search
May 2008
motuwethfrsasuw
   1234 18
567891011 19
12131415161718 20
19202122232425 21
262728293031  22
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.c++ Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Nested macros         


Author: The D0ct0r
Date: May 14, 2008 23:21

Hey,

please consider the following:

#if DEBUG
#define SOMEMACRO(type, name, value) (type) (name) = (value)
#else
#define SOMEMACRO(type, name, value) #define (name) (value)
#endif

If I define DEBUGging, i want the variable (name) to be a variable, but
if not, I want it to be a constant. When I compile this, the preprocessor
starts complaining at the fourth line, because of the second #define. Is
this OT here? And if not, how should I solve this?

the d0ct0r
2 Comments
  About initializing non-local object         


Author: WaterWalk
Date: May 14, 2008 20:20

Hello. When I consult the ISO C++ standard, I notice that in
paragraph 3.6.2.1, the standard states:
"Objects with static storage duration shall be zero-initialized before
any other initialization takes place."

Does this mean all non-local objects will be zero-initialized before
they are initialized by their initializers(if they have)? For example:

int g_var = 3;
int main() {}

Will g_var be first initialized to zero, then to 3?
25 Comments
  virtual constructors         


Author: katyusha
Date: May 14, 2008 20:19

why virtual destructors are possible but virtual constructors are not?
2 Comments
  Newbie question: How to define a class that will work on bits from a binary file?         


Author: Damfino
Date: May 14, 2008 18:26

Hi all,
Newbie question here wrt defining a class that will work on bits read
from a binary file. How would you go about doing it? As an example
please look at the structure of my data given below. The data comes in
40 byte packets via stdin or a binary file.
my_Data_pkt(){
syncByte (8bits)
XML_type (2bits)
XML_subtype (2bits)
record_value (3bits)
playout_flag (1bit)
if (playout_flag=='1') {
playout_length (8bits)
for (i=0; i< playout_length; i++){
playout_data
}
}
payload to fill the rest of the 40 bytes
}
How would this be defined as a class? ...
Show full article (0.77Kb)
4 Comments
  about the header file and source file in C++         


Author: stonny
Date: May 14, 2008 15:43

Sorry about the beginners question

In the header file, each time you define a class or function, it has
to be followed by a semicolon.
But in the source file, the functions do not have to be followed by
semicolon.

What is the reason for this?

Thanks
6 Comments
  about the private data member         


Author: stonny
Date: May 14, 2008 15:40

class Number
{
public:
Number(int num=0):private_number(num) {};

void compare(const Number & another_number_class) const
{
if(this->private_number == another_number_class.private_number)
std::cout<<"the two classes have the same numbers !"< else
std::cout<<"the two classes have different numbers !"< };

private:
int private_number;
};

In this class Number, the function "compare" can reach the private
data member of both current object and "the parameter object". Is this
because both objects belong to the same class?

stonny
3 Comments
  AdaBoost Question         


Author: Mark
Date: May 14, 2008 12:17

I'm using AdaBoost on optical flow data to learn to recognize human
actions. I've split my optical flow data into 5 channels (positive x,
negative x, positive y, negative y, and 'zero'). I know how to use
AdaBoost on a single channel, but I'm not sure how to combine the 5
channels to form a better classifier. Do I run AdaBoost on each
channel, and then pass the 5 outputs to another AdaBoost, or should I
simply concatenate the 5 channels and run AdaBoost once on all of
them?

Thanks,
Mark
5 Comments
  Class template specialization with template parameter         


Author: flopbucket
Date: May 14, 2008 11:27

Hi,

I want to provide a specialization of a class for any type T that is a
std::map.

template
class Foo
{
// ...
};

template
class Foo >
{
// ...
};

It seems to work - is this the correct way to do this?

Foo uses the normal template, but Foo > for any
types of T1 and T2 uses the specifalization?

Thanks
8 Comments
  Private inheritance question         


Author: KD
Date: May 14, 2008 11:19

Is it possible to privately inherit from a class while exposing as one
of the class' base classes?

For example, say I have the following classes,

class Widget { };

class Button : public Widget { };

Now I want to create a MyButton class that privately inherits from
Button for its implementation, but only exposes itself as a Widget.
In other words, I don't want the users of MyButton to be tinkering
with the Button part without going through the MyButton interface.

The kicker is that the code for Widget and Button may not be modified,
so I cannot make Button virtually inherit Widget and use proper
multiple inheritance.

Any takers?
2 Comments
  ===Welcome to comp.lang.c++! Read this first.         


Author: Shiva
Date: May 14, 2008 09:30

Welcome to comp.lang.c++! Read this first.

This post is intended to give the new reader an introduction to reading
and posting in this newsgroup. We respectfully request that you read
all the way through this post, as it helps make for a more pleasant
and useful group for everyone.

First of all, please keep in mind that comp.lang.c++ is a group for discussion
of general issues of the C++ programming language, as defined by the ANSI/ISO
language standard. If you have a problem that is specific to a particular system
or compiler, you are much more likely to get complete and accurate answers in a
group that specializes in your platform. A listing of some newsgroups is given
at the end of this post.

The FAQ (Frequently Asked Question) list has a wealth of information for
both the new and veteran C++ programmer. No matter what your experience
level, you are encouraged to read the entire list, if only to familiarize
yourself with what answers are available to minimize redundant replies.
The comp.lang.c++ FAQ is available at http://www.parashift.com/c++-faq-lite/

If the FAQ list does not help, then many regular readers of this group
are happy to assist with problems of standard C++. We have only a few
requests that we ask be adhered to, for the benefit of all:
Show full article (4.94Kb)
no comments
1 2