Thanks.
Type: Posts; User: Jefff
Thanks.
Not sure if this is the right forum section.
I am running the obsidian theme on Code Blocks, and I can not find a way to recolor the left margin (the part with the line numbers). It is always...
I feel confusion about pointers which I would like to remove.
void SomeClass::ConvertAndForward( int numbers, int targetvar )
{
//Send to member variable
targetvar = numbers;
I was planning to create a list of names, and have a program pick one out randomly and print it. Did not sound hard. Just grab some enums and....
well, .........
Apparently there is no direct...
Following manasijs advice I practiced the basics a bit more an I came up with a solution.
I copied the value from the pointer into a member variable which I created for this purpose which then could...
I am reading through my c++ about proper use of pointers but the specific problem I am having here does not seem to appear in there. (That or I am overlooking something). The mostly talk about
I...
I am trying to grasp encapsulation and I am getting confused on a few points:
1. Local variables in other functions of the same class
When I want to access a variable which is local to another...
After coding a small console application for testing out things, I sent it to a friend to try it out. However errors appeared talking about missing dll(?) files.
This is obviously a newb question...
Ah now I see. Guess I mixed up amount of array positions with their actual position names.
int tube_mag[6] = {0,0,0,0,0,0};
int *pMagPointer = &tube_mag[5];
void LoadBall() {
if (tube_mag[6] == 0) {
pMagPointer = &tube_mag[5];
"C++ without fear" uses this all the time, I was thinking it is the cool thing to do.
Is there a reason to use \n instead of endl? I find endl or <<endl much easier to type, because to type \n on a german keyboard I have to use ALT GR + the key next to 0, while <<endl can be typed...
Using the while-loop inside the function did the trick.
void menu() {
bool selection_invalid = true;
while (selection_invalid == true) {
cout<<"#########################"<<endl;...
Would calling a function itself create some weird and dangerous itself calling loop? The compiler warned when I tried.
Also this appears to run the function itself when assigning it to a variable:...
I found another issue where I would find goto useful, but what are the alternatives?
This function should restart itself when an invalid menu section is selected.
/* Main Menu */
...
I think I get it now. Following your explanation it goes like this:
cin>>x
takes whatever the user types in and stores it into x.
However since the user typed <number> and ENTER, this is put...
However avoiding
cin>>x;
is not really an option as far as I know, because I need an an int for my switch case. So if I type
cin.ignore();
it literally means remove 1...
Ok, so whenever cin>>somethings gets an input it floats around in the "buffer" until it is cleaned out. Which in this case messed up my program because the other functions skipped the input because...
Well I do not get why an input that was collected in menu() should mess up other functions. I mean it looks harmless, get user input, store it into a local x variable and be done with it. Why does...
Ok this appears to fix it. But why does cin>>x; mess up other functions of the program. I expected things in one function be "locked" inside it.
cin>>x;
As far as I understand this means store...
So, to pack it into a metphore, using a goto statement at the wrong time is basically as appropriate as running naked across the stadium during a football game.
While playing around a bit with File I/O I created a small test program. It displays a menu, from which the use can select two functions. One to write a string to a specified file and one to read a...
Yes, but I almost exclusively used for loops. Which look similar but easier to read.
Ok. *writes down note*
Would putting it all into a menu function be considered bad programming? Or is that just a recommendation for a different style?
For me, using the main function only...
No need to get offensive, I am just trying from a beginner standpoint to understand the reason behind the not-using of goto. I perfectly understand that an experienced c++ programmer has reasons to...