you have all kinds of issues with your code and it shows a lack of basic understanding of coding. If you are taking a class, you need to show this code to your teacher or get a tutor. If you aren't taking a class, then take one!
You clearly do not understand object-oriented programming. In this style of programming, you are dealing with objects, say for instance a house. Now, that house can have rooms. And it can have any number of rooms. Those rooms can have furniture...all different kinds of furniture. And that furniture can have different properties, such as fabric, color, size, etc...
This is what you're doing here. First, you're creating two new types of objects,
keyword tells the compiler that you are creating a new object type. Right away, though, you define
keyword), then you define record and then define a new object within
, also called
You don't use the struct keyword when you are trying to add an object to another.
In your case, record should just be:
int id, number;
But then, you are trying to access
without first accessing the record you are dealing with.
is an object within another object, so you first have to access its parent.
That's why you are getting that first error.
Then, you write
type which has no property called
As to the first two lines in your
section, like others have said, they do nothing.
You need to first access each worker object and then set the properties of that worker.
You also don't understand pointers. If you are brand new to programming, you shouldn't be using pointers at all. They will just confuse you. And in this case, you don't need them. Without the pointers, you could access a worker's name like:
worker.name = "Jack Bauer"
To access basic salary of a worker, you would want
worker.income.Basic_salary = 12.50;
And, you have your comparators screwed up in your if statements. You switched the less than or greater than sign
s with the equal signs.
It should be:
Also, you can't do a double comparison the way you did, you need to use the && comparator.
For instance, if you write:
int i = 5;
cout << "shouldn't get here";
you will get the message, even though 5 is not less than or equal to 2.
The reason for this is that it will evaluate the first part of the comparison (
). This will return
has an integer value of 1. So, then it evaluates the second part which would be
is less than or equal to 2.
It should be
if (3<=i && i<=2)
Seriously, take a class or get a tutor.