0
class BO2Offsets
{
    public:
        struct Prestige
        {
            u32 Offset { 0x000000 };
            char One { 0x01 },
                Two { 0x02 },
                Three { 0x03 },
                Four { 0x04 },
                Five { 0x05 },
                Six { 0x06 },
                Seven { 0x07 },
                Eight { 0x08 },
                Nine { 0x09 },
                Ten { 0x0A },
                MasterPrestige { 0x0B },
                CheatedPrestige { 0x0C };
        };
};
BO2Offsets BO2;

main.c

BO2 *BO3;

I'm creating a new element as BO2 but it's returned me an error:

error: 'BO3' was not declared in this scope

How can I resolve this ?
EDIT: When I declare BO3 like that:

BO2Offsets *BO3;

I use BO3 like this:

BO3->Prestige->Offset

And I'm getting an error: error: invalid use of 'struct BO2Offsets::Prestige'|

La J
  • 55
  • 1
  • 2
  • 8

3 Answers3

0

You need a typedef there. What you have right now is a variable declaration.

Change BO2Offsets BO2; to typedef BO2Offsets BO2;


As to your second question, you can't use Prestige like that because it is not data member. If you need to access the inner type, you need BO2Offsets::Prestige::Offset

Srikanth
  • 973
  • 2
  • 9
  • 19
  • Dont use typedef, is is obsolete in C++ – Jacek Cz Apr 03 '16 at 18:38
  • `typedef` is obsolete in C++? What? I know you don't need the C-style `typedef` for structs, but saying it is obsolete is a bit of a stretch. – Srikanth Apr 03 '16 at 18:39
  • introducing variables in C++ was simplified, and typedef lost his sense from old C. Deprecated in in-formal sense. – Jacek Cz Apr 03 '16 at 18:41
  • Doesn't matter. If you want to use `BO2` as an alias for `BO2Offsets`, you need a typedef. – Srikanth Apr 03 '16 at 18:43
  • 1
    I prefer the new style: `using BO2 = BO2Offsets;`, but they are [equivalent](http://stackoverflow.com/a/10748056/4944425). – Bob__ Apr 03 '16 at 19:00
-1

BO2 isn't type, is only variable name, and compiler want type.

use

BO2Offsets * B03;

EDIT: in the second place use

BO3->Prestige.anyName.Offset;

EDIT2; OK folks, if everyone edit his contents, I edit too: struct is improperly introduced, field cannot bee accessed. Now such concept compiles OK on modern GCC. BTW such introduction of Prestige isn't too useful, is similar like 'anonymous class' (to some degree). I allays declare struct / class at higher level. In this fragment can bee omitted.
But give name for field (my anyName) is important to access his internal fields.

class BO2Offsets
    {
        public:
            struct Prestige
            {
                u32 Offset { 0x000000 };
                char One { 0x01 },
                    Two { 0x02 },
                    Three { 0x03 },
                    Four { 0x04 },
                    Five { 0x05 },
                    Six { 0x06 },
                    Seven { 0x07 },
                    Eight { 0x08 },
                    Nine { 0x09 },
                    Ten { 0x0A },
                    MasterPrestige { 0x0B },
                    CheatedPrestige { 0x0C };
            } anyName; // here !!!
    };
Jacek Cz
  • 1,872
  • 1
  • 15
  • 22
  • 1
    You can't use `Prestige` like that. It's not a data member. And quit downvoting everyone in this thread. – Srikanth Apr 03 '16 at 18:40
-1

BO3 is nothing in your case.

You need to cast BO3 at first.

BO2Offsets BO3;

or

BO2Offsets *BO3;
Sonikk
  • 39
  • 5