beginner question on successive factoring

P

pauldepstein

I'm unable to interpret this code snippet:

const A& B::C::D(const unsigned short E) const
{
return F(E)->D();

}


[Above is a verbatim copy but names were replaced by A, B, C etc. to
preserve confidentiality.]

In particular, I'm unused to seeing the a::b::c structure.

Thanks for your help,

Paul Epstein
 
J

Jerry Coffin

I'm unable to interpret this code snippet:

const A& B::C::D(const unsigned short E) const
{
return F(E)->D();

}


[Above is a verbatim copy but names were replaced by A, B, C etc. to
preserve confidentiality.]

In particular, I'm unused to seeing the a::b::c structure.

Think of something like:

class A {
int x;

public:

class B {
class C {
int D(const unsigned short E) const;
};
};

A(unsigned short E) : x(E) {}
};

const A& B::C::D(unsigned short E) const {
return A(E + 1);
}
 
V

Victor Bazarov

I'm unable to interpret this code snippet:

const A& B::C::D(const unsigned short E) const
{
return F(E)->D();

}


[Above is a verbatim copy but names were replaced by A, B, C etc. to
preserve confidentiality.]

In particular, I'm unused to seeing the a::b::c structure.

'B' is either a class or a namespace, 'C' is a member of 'B', and is
also either a class or a [nested] namespace, 'D' is the name of the
function.

namespace B {
class C {
A const& D(unsigned short) const;
};
}

or

class B {
class C {
A const& D(unsigned short) const;
};
};

V
 
J

Juha Nieminen

Jerry said:
class A {
int x;

public:

class B {
class C {
int D(const unsigned short E) const;
};
};

A(unsigned short E) : x(E) {}
};

const A& B::C::D(unsigned short E) const {
return A(E + 1);
}

You are declaring D to return an int and to be inside A::B::C,
yet in the implementation you are saying it returns a const A& and that
it's inside B::C.

I doubt that would ever compile.
 
J

Jerry Coffin

[ ... ]
You are declaring D to return an int and to be inside A::B::C,
yet in the implementation you are saying it returns a const A& and that
it's inside B::C.

Oops -- quite right. My apologies for the slip-up.
I doubt that would ever compile.

It shouldn't at any rate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top