Re: question

From: Leor Zolman (leor_at_bdsoft.com)
Date: 05/14/04


Date: Fri, 14 May 2004 01:31:13 -0400

On Fri, 14 May 2004 16:16:24 +1200, "CTG" <dontbother@yoohoo.com> wrote:

>if i have a class with only a private member function say a long
a "long"...where's this long?

>so teh construction would be
>==================
>class A(const int l)
>{
>public
>
>private:
> int l;
>}

If you're trying to say:

class A
{
public:
        A(int l);
private:
        int l;
};

then it would help if you actually said that. When you show code that is
so incorrect (not to mention at odds with the words you use), it is very
difficult to figure out what you're thinking...let alone what might be
causing your error. Once again: PLEASE submit code to your compiler, and
show us the same code that your compiler saw if you tell us about an error
and wish some sense to be made out of it. If you've actually done that,
then there must be lots of errors you're totally ignoring. That's not a
good thing to do.

>
>A::A(const int lparam)
>{
>l=lparam
>}

ok, that one looks good. The right number of colons and everything. Except
for the "long" part you mentioned; all you have are regular old ints. But
that's cool.

>==================
>
>and then
>have another class
>class B
>{
>public
>
>private:
> A s ;
>}

So, now perhaps you mean:

class B
{
public:
        B(const A &paramA); /* please pick one of these two... */
        B(A paramA) /* did any of what I told you about const get through? */
private:
        A s;
};

>
>in the construction of B
>B:B(const A paramA)

Either:
        B::B(const A &paramA)
OR:
        B::B(A paramA)
>{
>s=paramA /// CAN I DO THIS ???????

Sure, you should be able to, if the preceding code were to be correct. Why
did you get the error? Who in God's name can tell, when you either haven't
shown us the code you've actually tried to compile, or you've ignored all
the previous errors? And if this IS the code you've actually tried to
compile, you'd have to fix the umpteen errors you would have gotten
previous to this one, before it makes any sense to think about this one.
For one thing, the compiler probably would have choked on your definition
of class A, so it wouldn't accept a subsequent definition of an A object
(such as s)...
        -leor

>}
>
>well teh compiler does not like it
>rror C2065: 's' : undeclared identifier why?

-- 
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix  
C++ users: download BD Software's free STL Error Message Decryptor at:
   www.bdsoft.com/tools/stlfilt.html


Relevant Pages

  • random number code
    ... Will it really compile exactly the same as mingw compiler used ... // initialization of static private members ... MSBs of the seed affect only MSBs of the array ... // constructor with 32 bit int as seed ...
    (comp.lang.cpp)
  • Re: C++ in ternms of C
    ... int b, c, d; ... To consider the other aspects of OOP, we obviously have public, private and ... In short, imagine the compiler ripping all of the functions out of a class, ... I tried to analise the ASM file produ ced my the VC++ compil er. ...
    (microsoft.public.vc.language)
  • Re: It Pays to Enrich Your C Skills
    ... Check if you can score a perfect 10 (without using a compiler). ... int main{ ... struct bitfield { ... out if it is a negative integer constant or a constant expression ...
    (comp.lang.c.moderated)
  • OT: Re: Perl Peeves
    ... I see the result of a test being used as an int. ... the compiler just assumed you knew what you were doing ... introduced to the language later, so void * was unheard of in most code. ... This didn't mean bool was special, declaring it just signaled to the ...
    (comp.lang.perl.misc)
  • Re: OT: Re: Perl Peeves
    ... when I see the result of a test being used as an int. ... compiler just assumed you knew what you were doing and would ... This didn't mean bool was special, declaring it just signaled to the ... What "normalization of bool results is built into the compiler"? ...
    (comp.lang.perl.misc)