|
| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
What must I know to do this in C++?
|
Original Message
|
Name: Jack-R
Date: November 20, 2002 at 11:23:08 Pacific
Subject: What must I know to do this in C++? OS: win98 CPU/Ram: P3
|
Comment: Hi. Some of you may remember my question about OOP design. This question has something to do with that, except, OOP isn't necessarily required for what I am wanting to do. I was wondering what type of programming knowledge I must have to do the following in C or C++: Write a program that creates a simple checking account with a unique name and password for a particular user. The account will have a balance that a user may deposit in and withdrawl from. Some of this, I can do already(although I'm not too sure about the password part). The problem is, although I can do this, the user's data is completely gone after runtime. What do I need to know to "store" the users' data? Do I need to know about databases and all of that? Also another question: At what point in my learning, can I consider myself having any type actual marketable skill? Thanks for your time. Jack
PS: This is just an extra question I guess. If you would rather not answer it (or any of the above for that matter), then that is perfectly fine. As a matter of fact, I guess its not really a question. Anyway, if someone could "lecture" on the following, in a way that might increase my understanding boolean algebra/logic, I would appreciate it. There are no definite rules for talking about what follows. Just feel free to elaborate on it, discuss what it means to you, or how you interpret it:
1||0= TRUE 1&&0= FALSE
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Don Arnett
Date: November 20, 2002 at 11:52:35 Pacific
|
Reply: (edit)Regarding the boolean logic 1 indicates TRUE 0 indicates FALSE || indicates boolean OR (as opposed to bitwise OR in C/C++) && indicates boolean AND So the first statement says: true OR false equals true The second says:
true AND false equals false If you are an english language speaker, it should make sense if you think literally about the meaning of the words.
Answer the questions, based upon the following statement: If you clean your room OR you wash the dishes, you may eat the candy. I cleaned my room, so may I eat the candy?? I washed the dishes, so may I eat the candy?? I cleaned my room and I washed the dishes, so may I eat the candy? With an OR statement, if one or both sides of the OR are true, the whole statement is considered true. It doesn't matter which is true, as long as at least one is true, the whole statement is considered true. But, answer the same questions after you change the OR to AND:
If you clean your room AND you wash the dishes, you may eat the candy. With an AND, both things have to be true in order for the statement to be considered true.
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Jack-R
Date: November 20, 2002 at 14:49:18 Pacific
|
Reply: (edit)"If you clean your room OR you wash the dishes, you may eat the candy." "I cleaned my room, so may I eat the candy??" yes "I washed the dishes, so may I eat the candy??" yes "I cleaned my room and I washed the dishes, so may I eat the candy?" yes My confusion is due to the fact that 1 and 0 are not(at least how I see it) being used to represent specific entitites.
I can, however, understand this: A B A||B 1 0 = 1
"A||B" says, "A is true, or B is true". In the case of A=1, B=0, A||B is in fact true. The only event in which A||B is false is when both A and B =0. But just using 1 and 0, while neglecting to associate those values with any specific "entity" or statement, causes me some confusion. Also, Does || equal " is true" ? Because if that is EXACTLY the case, I MAY be able to see how 1||0=1(or any other truth statement involving only 1's or 0's for that matter) Jack PS: I chose only to deal with OR in this post simply for that fact that also using AND in this dicussion would unecessarily prolong it. As to why I chose OR over AND, I am not certain.
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Jack-R
Date: November 20, 2002 at 14:54:19 Pacific
|
Reply: (edit)I need to edit something in the above post. "Does || equal " is true" ? "
It should read: "Does || equal "(--ThisORThat--) is true?" " except ( should be less than and ) should be greater than. I was trying to use the inequality signs as arrows.
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: BuBu
Date: November 20, 2002 at 15:09:25 Pacific
|
Reply: (edit)You would need to store the data in some kind of file and read it in and it out at run time using file streams. It may be too long to explain here. If I were doing it I might use a class 'USER' who has certain attributes lets say for simplicity 'AccNum' and 'balance'(even though there are at least 50 things that could be tracked for each transaction. The file would look something like: Jack;123456;2000.24 BuBu;123457;4.22 etc... You will instantiate each class member as you read the record. I would replace each record that is changed everytime it is changed. As for when you have a marketable skill, knowing when and how to look and ask for help is a skill that eludes most programmers that I know. Keep learning and asking questions and you will have the reward of knowledge which will bring you $$ eventually Good luck...
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: Guy
Date: November 20, 2002 at 17:07:33 Pacific
|
Reply: (edit)Jack - In the really old days, we used to (with pen and paper) draw tables, which we called 'truth tables'. There are 3 basic operations: AND, OR, XOR. The basic tables are: false AND false = false false AND true = false true AND false = false true AND true = true false OR false = false false OR true = true true OR false = true true OR true = true false XOR false = false false XOR true = true true XOR false = true true XOR true = false Even if this does not make sense, just memorize them. It will take you a long way. HTH, Guy
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: tru
Date: November 20, 2002 at 18:23:15 Pacific
|
Reply: (edit)For a statement to be true: AND - They must all be true OR - At least one must be true XOR - One must be true while the other is not That's a simple breakdown.
Report Offensive Follow Up For Removal
|
|
Response Number 7
|
Name: Jack-R
Date: November 21, 2002 at 07:53:16 Pacific
|
Reply: (edit)BuBu, Thanks for the advice. I take it that since you did not go into details as to how one might accomplish that task; that it is over my head for the time being any way. What should I learn to prepare myself for doing this? Guy, I have worked quite a bit with truth tables. Pure memorization is something I do not want to do as that does not indicate genuine understanding. tru, I am familiar with the rules and everything. I am pretty much seeking some "click" in my brain that tells me I understand. It is hard to explain. Thanks to everyone for your attempts to help me. I do appreciate your efforts and your patience. However, a more appropriate place for this problem is probably a psychiatrist's office rather than a programming forum. I will attempt to refrain from posting anything of this ilk in the future. I sincerely apologize for my posts about this whole logic matter.
Report Offensive Follow Up For Removal
|
|
Response Number 8
|
Name: SN
Date: November 21, 2002 at 10:39:47 Pacific
|
Reply: (edit)Jack- If people don't want to read or respond to your posts, they don't have to. As for me, I think they are interesting and stimulate educational discussion. Don't apologize. We obviously don't really understand your question with logic, since we haven't even come close to addressing it yet. Maybe if you can explain it more clearly... If it helps, remember that when it comes right down to it, ALL mathematical operations are merely defined operations that give predictable output based on input. There is no rule that says operations have to model the real world. If I wanted the operation OR to be false all the time regardless of input, I could certainly define it to do so. (although I can't say for sure whether my definition would be accepted by my colleagues:-) This is why memorization is really not as bad as it may seem - you are only memorizing "arbitrary" rules that some person way back when decided might be useful. Memorization of the patterns would, of course, be more useful than memorization of the rules. I do not mean to say that mathematical operations, boolean, logical, or otherwise, do not tend to mimic the real world - they would be useless if they did not. However, a complete understanding of how they mimic the real world is secondary to understanding how they can be used to solve problems. As to your programming file io question, you probably would catch on to how to do this after looking at any file io example. It is just like keyboard io, just with some extra definitions at the top. Good luck, SN
Report Offensive Follow Up For Removal
|
|
Response Number 9
|
Name: Jeff Graver
Date: November 21, 2002 at 13:16:50 Pacific
|
Reply: (edit)A => I think I know what I'm saying B => I do know what I'm saying if A && B I should speak up. if A || B the issue is still in doubt. Jack - if I read your responses correctly, I think the answer to your plexation is that in C and C++, 0 stands for FALSE and 1 for TRUE by convention with no other good reason to back it up. A || B is actually an expression (just like A + B, A - B, etc) that evaluates to 1 if either A or B is non-zero, and A && B is an expression that evaluates to 1 if both A and B are non-zero. The operators || and && only mean that something is "true" to the extent that 1 is taken to mean "true", which is to say, it works pretty generally in C and C++, but I've seen programs where TRUE is defined as 0 and FALSE as -1, in which case almost any use of the || and && operators is likely to result in errors. The "equals" operator, ==, is also used to make expressions. C == D is defined as 1 if C and D are equal, 0 if they are not. Finally, let me point out that the "if" statement in C allows you (among other things) to execute a statement of code if and only if a particular expression evaluates to 1. So then, let's say you want to write the statement "if A or B is true then ..." in C. Accepting the convention that 1 => TRUE, you can write "if ( A || B == 1 ) {...};". But you can shorten this (since the expression 1 == 1 always evaluates to 1) to "if ( A || B ) {...};". Note that the operators | and & are quite different than || and && and will cause you considerable confusion the first time you use the wrong one by accident. Helpful? Jeff
Report Offensive Follow Up For Removal
|
|
Response Number 10
|
Name: WGF_CyberSabre
Date: November 21, 2002 at 18:28:43 Pacific
|
Reply: (edit)add (this is using codewarrior 7 pro) #include //in int main() ifstream infile; //ifstream is used when u take from a file to the project. ofstream outfile; //ofstream is used when u output the data to a file. outfile.open("filename.txt"); //it will make a new file. path will be the same as the project *.mcp infile.open("filename.txt"); //it will open the file if it exists, use assert to make sure it does. also u might be better of using ofstream part first. //when taking data from infile do. infile>>variable; //it will not consider spaces and end line and go to the next available variable; //outputing the data to outfile. outfile<//use spaces to make sure what u get is right also use endl when changing names. outfile.close(); infile.close(); //also one file may only be in outfile or infile...so make sure u dont do what i have dont and only open the file one at a time.
Report Offensive Follow Up For Removal
|
|
Response Number 11
|
Name: Jack-R
Date: November 22, 2002 at 09:25:04 Pacific
|
Reply: (edit)SN, I appreciate your encouragement. But my posts about logic are really futile. Someone's lack of understanding of my posts is not that person's fault at all. Any lack of understanding is due to the inherent ambiguity of the matter. You see, even I do not know what it will take to satisfy this thing. I try and I try to argue with it, and rationlize with it, but it does not work. Its like my mind is demanding something but it does not tell me how to get it, or what exactly it wants. It is hard to describe exactly what I am seeking. I described it before as a type of "click" in my brain. Something that tells me "Oh this is definitely it". I guess it is the proverbial light bulb that all of a sudden lights up, which I am waiting for. But then again, even after I experience a click, that click can later be nullified,devalued or viewed as invalid by my brain. Jeff, Thank you for your effort. As I believe you may have noticed, my problem arises not when confronted with real-world examples of logical OR AND arguments, but when the statements are substitued with 1 or 0. However, it is not the fact that it is 1 or 0, but that these are truth values. The association between 1 and 0, and true and false, respectively, is pretty solid in my brain. The difficulty arises not from the association but from the fact that these are only truth values. I have another way to look at this though. However, I have had numerous "clicks" with this matter, but they have later came to be nullified. The thing is, 1 and 0 being used to replace values is actually meant to simplify something so that the validity of an individual statement need not be verified but the validity of the entire compound statement can be assessed. It is meant to save some one the trouble. Either that, or it at least has the cabability of saving someone trouble. Logical OR is employed by a statement or fragment to make a claim. OR's claim is, that at least one of its operands is true. Where 1,0,true, or false, is used, one is merely saved the trouble of evaluation individual statements. If OR was a prefix and its operands were enclosed in a box like this: OR[A,B] It would say something like "One of my operands is true". Well, at this point, we can't evaluate the validity of that statement, because we have no truth values. In this case, however, we can: OR[0,0] This statement would be false, of course because this statement just said "One of my operands is true". So it pretty much just lied. I am going to try to demonstrate this using brackets. I will try to use a tag to let me post the brackets, I hope it works. If it doesn't work, ignore everything between the dotted lines. ----------------------- OR(||, v) translates as In the case of 10 We need only to look at the values on each side. 00 In this case, the statement is false. -------- Again, I worked only with OR in this post, the same of course can be said of AND when used in the proper context. Also, you know what really sucks about this? Often, I get to the point where I give up. And say to myself, this is not something I can beat without the help of a psychiatrist. But soon, the thought will keep coming back. I will think that maybe, just maybe this next way I thought of might be *it*. "This one might really work!" "Besides, I HAVE to know these things. I can't give up. I must be sure that I know this.". And so, I am coaxed back into a futile battle with this thing. I do not intend to anthropromorphisize this condition. But then again, maybe it is anthropromorphic in nature, as it is, an aspect of my consciousness. In my words, I try to distance it from myself, by saying my "condition". But perhaps it is not so distant. I don't know. All I do know is that this is hell. Cybre Sabre, I'm afraid your example is beyond my current capabilities. I will need to learn more before I can do this. I'm sure I have a lot of work ahead of me. For example, it looked like you used pointers in your example, but I am not familiar with them. Thanks for trying though. PS: Unfortunately, the text between the dotted lines did not work. I noticed it in the preview part of the post. But I'm not going to bother editing it out. Just in case no one is entirely convinced of my idiocy. (by the way, I used the "textarea" tag)
Report Offensive Follow Up For Removal
|
|
Response Number 12
|
Name: tru
Date: November 23, 2002 at 20:12:33 Pacific
|
Reply: (edit)Truth is only defined by the situation. It seems that you know what the OR and AND operations do. In the situation of computers languages, typically anything that isn't zero is considered true. For real world examples truth is whatever you want it to be.
Report Offensive Follow Up For Removal
|
|
Response Number 13
|
Name: Jack-R
Date: November 24, 2002 at 16:43:23 Pacific
|
Reply: (edit)Thanks for the advice tru. But now my obsession has changed. Its still logic related, but it deals with this now: Pv~P I just thought I would let you know I'm on to something different now. I found this obsession as I was seeking a "cure" for the last one. Now, I feel like I understand the last one, but I feel I lack the "proper" understanding of this. But I am just going to try and ignore this and go about my business. But it is so hard to ignore these things. It just keeps bugging me. I will just keep trying to focus on learning programming. Because of crap like this, I make no progress whatsoever.
Report Offensive Follow Up For Removal
|

Post Locked
This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
Go to Programming Forum Home
|
|
|