Question
typedef struct error{int warning, error, exception;}error;
main(){
error g1;
g1.error =1;
printf("%d",g1.error);
}

Answers

Answer
1
Explanation
The three usages of name errors can be distinguishable by the compiler at any instance, so valid (they are in different namespaces).
Typedef struct error{int warning, error, exception;}error;
This error can be used only by preceding the error by struct kayword as in:
struct error someError;
typedef struct error{int warning, error, exception;}error;
This can be used only after . (dot) or -> (arrow) operator preceded by the variable name as in :
g1.error =1;
printf("%d",g1.error);
typedef struct error{int warning, error, exception;}error;
This can be used to define variables without using the preceding struct keyword as in:
error g1;
Since the compiler can perfectly distinguish between these three usages, it is perfectly legal and valid.

Note
This code is given here to just explain the concept behind. In real programming don’t use such overloading of names. It reduces the readability of the code. Possible doesn’t mean that we should use it!   Your Comment






Search
Can you Answer!!
  • Q What are the family and order of Airsac catfish ?
  • Q Expand FCNRA ?
  • Q Which was the summer capital of British India:
  • Q What is lexical reference? how can it be created?
  • Q Explain the Session state management options available with ASP.NET?
  • Q Who is the new Chief minister of Haryana ?
  • Q Which law is broken most frequently?
  • Q How to prepare and store agar?
  • Q Describe the different steps involved in Paraffin Microtomy.
  • Q What are the social and economic benefits of advertising? Does advertising really contribute to improve our standard of living?
  • Q What To Do If the Binary SPFile Is Wrong for the Default Instance?