Where do you put typedef?

Feb 4, 2013 at 3:53am
Do i need to put typedef in main or in my class? or do i make it global? Do i put it in a seperate function? what d i do with typedefs?
Feb 6, 2013 at 12:22am
bump
Feb 6, 2013 at 12:55am
A typedef has whatever scope you define it to have.

If you create a global typedef, then the typedef has a global scope and is visible throughout the program.

If you create a typedef within a class declaration, then the typedef is known within that class. It can have public, protected or private visibility depending on where you define it within the class declaration.

If you define a typedef within a function, then it is only visible within that function.

Topic archived. No new replies allowed.