MS Vis Studio "not a type"..??? error

Pages: 12
Since you're still getting used to VS, try a few things like this:

Set a breakpoint on the isbn.at(i) line. To do that (with conventional keyboard setting), put the cursor on that line and hit F9.

Run - F5 - it stops on that line.

Open a watch window (debug/windows/watch1)

Place it where you like

Add to the watch i, then another line, ch, then another line, isbn (and expand isbn).

Step forward with F10 (step over function calls) or F11 (step into function calls) and watch the exception happen.

Then, open the call stack window (debug/windows...)

Click on the stack where you recognize your own function name(s), like main.

There's more, of course, but that's basically how I saw ch was 53, used as in index when it's actually a character from isbn
Niccolo,

I'll try to run it in debug mode. Hopefully I can figure out the IDE and the code at the same time! LOL. I think it is also failing on the test at the top of MAIN right after instantiation for some reason....

Xanadu
Niccolo,

I see what you're trying to show me..... I see a "53'5'" inside of ch.…. so I suppose this will NOT work with isdigit() because it is a character? Or am I thinking about it all wrong?


I see that it is failing here and is that because I have the wrong type to check inside of isdigit()? Or am I testing it wrong? Should I be saying isdigit(ch)>0??


Xanadu
Niccolo,

I had to use a switch statement (for some odd reason instead of isdigit() ) and I'm not sure why.

I am also observing odd behavior==> after the "is_book()" test happens and PASSES the object is instantiated BUT none of the initializer values are placed into the member data in the book::object.

Hence, when I try to test the member values with the "cout" statements that utilize the "get" functions, I get nothing but blank white-space because the members are never successfully filled with the data.

How is THAT working? Do I need the "NEW" keyword or something? I am not seeing why my_book doesn't fill with the initialized values even after all the data is verified during the constructor process.

Any ideas about what is going on here?

Xanadu
Nowhere in your overloaded constructor are you actually setting the values of your data members. You check that the arguments passed in are valid, but do nothing else.

And, on the subject of the check - you're not really achieving anything by checking it in the cosntructor. You're outputting a message if it fails, sure, but the object still gets constructed anyway, and the calling code will proceed regardless.

Wouldn't you be better off doing that test before you construct the object, and then handling failures in some sensible fashion before creating the object?
Last edited on
@Xanadu4ever,

I probably can't see what you're seeing now, so a new post of your code may be in order for us to see what you do....original code has isalnum (I think)...and no switch.

Mikey,

I was under the impression that an initialization list initializes data...... is that not what is going on here? Is an initialization list used for something else? Do I have to add other steps for it to work?

Do I need to explicitly make a statement like class::object.member = data; or something to that effect? Again, I am taking a lot of these examples from a book by Dr. Strousstrup so sometimes I wonder why he is having us perform certain tasks in a certain manner. But I can't blame everything on him either since I am relearning modern C++. Not completely sure at times. However, the sample code he offers seems to suggest that the initialization list should initialize the member data and set its values.

If that is NOT what it is doing maybe you could give me EXPLICIT details of what you are generally implying....??

Also, to the topic of the test when I step through this code in the debugger the test seems to take place BEFORE the instantiation of the object ..... so it seems to be checking before the object is created. True, there is only a simple statement there now for debugging but I could definitely exit out of that function instead of creating the object if it fails. Just testing as I go along. This isn't finished by far.

Niccolo, I can post the updated code code but it will be tonight as usual.

My question from the original code that is posted is why isn't the "isdigit()" calls working? Am I using them incorrectly? I looked up the usage (from the reference section here on this site) and it appears I am using them correctly so I am not sure why they are failing unless some #include needs to be added or what have you....

Do you have a specific idea you are trying to tell me?

Xanadu
I was under the impression that an initialization list initializes data......

Yes, it does. Or it would do if the constructor actually, y'know, had one. (I'm talking about your overloaded constructor here, not the default one.)

Do I need to explicitly make a statement like class::object.member = data; or something to that effect?

That would be another way of achieving the same thing. You don't need both that and an initialisation list.

If that is NOT what it is doing maybe you could give me EXPLICIT details of what you are generally implying....??

Your overloaded constructor does not have an initialization list. Nor does it have any other assignment of values to the member data.
Mikey,

I appreciate your time and help but I need to address something with you here and now and for anyone else watching this thread.

I'm not sure what you're issue is but you can drop the attitude garbage. Y'know?? NO, I don't know... hence the questions. See how this works?? If I knew I wouldn't ask to waste anyone's time. I would implement! See attitude comes across very poorly doesn't it?

Do you like it when I condescend back to you?

I am merely here trying to get advice and help on a specific question, if you want to work in vague generalities and try your luck at coming across as unprofessional while implying I don't know what I'm doing (surprise I don't! That's why I'm learning and asking questions!) then keep your advice to yourself. I don't need that type of help and you'll find neither does anyone else that's trying to get better.

If you have a specific detailed point to make then do it. The unprofessional off-handed quips aren't helping your cause.......perhaps if you just came out with a specific comment and said something to the effect like this==>

"You're code is wrong because of this fact <insert fact here>. You should do it THIS way <show specific example or direct to specific topic here showing why THIS way is superior> NOT the way you (person asking for help) are doing it. The way YOU are doing it is faulty because of <insert reason for bad logic or error here>."

I try to be very professional when asking time from others and I value their input and effort and I realize many of you here see dumb questions like this all the time. I am grateful for the help and appreciative and even admit most of it is just rudimentary stupidity on my part.

However I don't and won't put up with the attitude from anyone. If you don't want to help and be professional because it is some-how beneath you then ....... don't! It really is that simple. Just ignore the post and let someone else give input.

I will continue to be professional and would ask the same of you.

Now, if you have something specific to critique on my code... have at it. I am convinced it is really wrong and poor code and it is an exercise I am going through to get better and more experience.

Keep your attitude at wherever you call home though. I don't need that.

very respectfully (but firmly),

Xanadu
I was being conversational, not condescending. Do try not to assume bad intent by the people who are actually taking time and effort to help you out, for free.

But since you've decided to be hostile, I'll say this: your "Poor little me, I have no idea what you're talking about, and you're just being mean to me" act rings hollow.

You clearly do know what an intialization list is, because you've written one for your default constructor, and demonstrated in your posts that you know exactly what it does.

It should therefore be well within your grasp of the language to see that you haven't written one for your overloaded constructor.

And with that, I'm out. I'm not going to continue to help someone who responds in such a spiteful and ungrateful fashion.
Xanadu wrote:
Why isn't isdigit working?
I don't see code that is using isdigit.

Might be worth noting a confusing aspect of terminology... I'm not even 100% of the terminology myself, but:

• In "MyClass(int x, int y) : x(x), y(y) { }", the " : x(x), y(y) " part of the the constructor is called the "member initializer list".
https://en.cppreference.com/w/cpp/language/initializer_list
cppref wrote:
In the definition of a constructor of a class, member initializer list specifies the initializers for direct and virtual base subobjects and non-static data members. ( Not to be confused with std::initializer_list )

But the calling side, MyClass obj {2, 3}; is one of the ways of doing "value initialization".
https://en.cppreference.com/w/cpp/language/value_initialization
I'm not sure if the braces have specific name beyond just being braces in this case.

But {2, 3} can also be treated as an std::initializer_list when the constructor accepts one, such as for std::vector.
Last edited on
Thank you Ganado,

Yes, I also thought the {}'s would initialize MEMBER data as well (maybe "initializer list" was poor terminology on my part??)

As to the isdigit() you are correct...... I meant isalpha() in the code on the previous page. I realized this was an error and had to change it BACK to isdigit() instead. However, when I changed it BACK to an isdigit() - I was still not able to get it to work.

As I mentioned to Niccolo above, I work on this stuff at nights so I will have to post the CURRENT version tonight if you want to wait? LOL. Don't blame you if you don't!!

but I had to switch the isalpha's and isdigit's to a switch statement to test them rather than use those functions....... there is a reason just not sure what it is at the moment.

Thanks for the help.

Xanadu

Mikeyboy,

I had the day to think about my reply and I apologize and after reading what you were saying and understanding "your style" of communicating and probably due to my frustration and lack of sleep (no excuses for bad behavior though... I'm still solidly in the wrong!)

I jumped the gun and bit your backside. THAT was not professional on my part.

I apologize and am man enough to admit when I've screwed up - and I did. Hopefully this won't be a permanent damage upon you giving me advice from now on. But if it is.... I get it and don't blame you in the least - I've earned it fair and square.

I did learn a lot from what you said and appreciate it. Finally got it to work. I was legitimately doing NOTHING with the data when it was passed into the function instead of assigning it to member - regardless of whether direct assignment or a list.

It was my unprofessional error to respond the way I did and I am saying this now to correct the situation and make sure I don't do it again.

No hard feelings and I will definitely relax when it comes to reading help from others and not just assuming they are trying to smart off.

Thanks for your help and again, I was in the wrong and you were not.


Xanadu

Thanks for posting that - I appreciate it. No hard feelings! Glad you were able to get your code working.
Last edited on
Thank you sir.

I also was able to get my head and my ass wired together! Again, completely sorry for the uncalled for response and behavior!

Thanks for your advice. I just needed to stop, read it and then do it!

respectfully,

Xanadu
Been there, done that, bought the T-shirt.




Topic archived. No new replies allowed.
Pages: 12