C++ :: Making Namespace - Show Variables And Functions Into Compact Area
Sep 13, 2013
I know how to make a namespace i just want to know why someone would. because it just seems like a way to show a bunch of variables and functions into a compact area.
I'm trying to make a class constructor within a namespace and I keep getting errors like: "'<variable>' is a nonstatic data member of class '<class>'" for when I try to setup parameters, and "Incomplete type is not allow" whenever I try to write out my function definition. Here's what I'm doing:
namespace test { class blah; } class blah { typedef int var[5];
[Code] .....
Also I'm unsure why there is a parameter of 'const blah &' when I mouse over blah(); (using Visual Studio 2010) within the class definition. It tells me 'blah::blah(const blah &)' and I am unsure where the parameter comes from. How can I resolve these issues?
I got an assignment at school asking for a program that can implement functions that store, get and deletes text/binary data to a given memory area. We are supposed to make kind of like a tiny-mini OS..any links to some tutorials or explanations hon ow to understand this and be able to make a program like this on my own?
Every time screen2() runs it always outputs "Numbers entered were 0 and 0". I want the numbers that were entered in by the user in screen1() to be displayed.
I have this code where I am trying to retrieve the contents of the variable dev1 and dev2. for some reason when i compile and run I am getting 0 and 0.
I'm truing to write a function that gets an array of arrays, and returns an array. I placed the code I'm using below, but I'm getting all kinds of errors. How is the right way to do this?
Now the book says to take the following program and add a member function to the CarType class which prints the values of all of its data members. Add two more data members which are relevant for cars. Add the use of these data members to the program (to the assignment statements for MyCar, to the operator prompt and input inside the getYourCar function, and to the print function you have created).
Here is my code. Whenever I run it, it takes my assigned variables in MyCar and prints those instead of the one which the user is inputting.
#include <iostream> #include <iomanip> #include <string> using namespace std; using namespace std; struct CarType { string maker;
I have a project for class where I have to create a structure and get user input for 3 structure variable arrays of 10. I am trying to figure out how I can use the same function to fill my different section of variables.
My Structure is an employee file of ID number, name, hours, payrate, and then gross pay. I have to create a function for each input function. I am confused on how to pass the structure variable so that I do not have to write 3 functions for each input. I would like to be able to get all the info for the first structure variable and then recall the same 5 functions for the next before moving along. I hope that I have been able to make this clear. Here is my code:
It is said that variables in a function cannot be changed by another function. Only by using pointers can variable values be changed. I am writing some functions to try to prove this theory, but I can't get it right.
Code:
#include <stdio.h> #include <stdlib.h> int main(void){ int x = 10; printf("default x value is %d ",x);
[Code] ......
Code:
#include <stdio.h> void try1(int x){ printf("x in try1 is %d ", x); x++; printf("x in try1 after ++ is %d
I need making my main function to run while not having any if or for statements. It can only declare variables and functions. Since my main function has command line arguments, how to so.
// This program counts all the words in a given file.
There are, or course, better ways to do this, but I need to stick to some rules:
(1) Use only pointer variables and not arrays or structs. (2) Use the three functions shown--regardless of easier methods.
The program should ask for some input, operate on those numbers, and then display the results. I know I am confused over these things:
(1) All that syntax using '*' and '&' or neither. (2) How to use the char type correctly. (3) How to use a char type input as an operator (a + b). (4) How to use the pointer of the operator variable (+,-,*,/) in an actual equation.
So I need to make a main function have no if/for/etc. statements so I need to move it to another function and call it in main. The problem is that it's a command line argument function so I'm confused on how it works. Here's an example:
Code:
#include <stdio.h> int main(int argc, char* argv[]) { printf("The program name %s", argv[0]); if (argc == 2) { printf("Argument supplied is %s", argv[1]); } else if (argc > 2) { printf("Too many arguments");} else { printf("One argument");} }
How can i make this into two functions with main only declaring variables and calling other functions?
Data structure problem. I have a table of the following format:
Code: C/R 1 2 3 4 5 6 7 ... 1 x x x 2 x 3 x 4 x 5 x x x 6 ... s
So my column and row names are integer numbers if an outcome of some game for a certain column and row lable is a match then we have an x on that position. The size of the integer names for both column and row name is quite large (let us imagine that it is so large that you would need a machine with 500GB of RAM memory to hold this type of table even if x's are treated as regular char's) . In every row there is at least one x and for every column the same holds for the columns. However, the number of x's for a row or a column can be bigger then 1. How to store this table efficiently? (using as less memory as possible).
The data structure should be efficiently accessed in the column fashion that is, if i want to get all values for column 4 I should be able to do that in O(N) time where N= the number of rows.
My specific request is for retrieving values that are stored to a CompactFlash card. I am able to store values (we call them recipes) to the CompactFlash card as .csv file. I just haven't been able to figure out the code to retrieve this information back to the touchscreen.
Code: // Create a new folder if it doesn't exist CreateDirectory("/recipes"); //Create the file if it doesn't exist CreateFile("/recipes/recipe.csv"); //open the file hfile = OpenFile("/recipes/recipe.csv", 2);
[Code]....
Now with that said, I would like to retrieve these values from the .csv file.
i know using namespace std; is important to wite as it contain cout,cin,etc........but is that namespace std is contained inside iostream header file OR iostream header file is contained inside namespace std ......
It seems as though more experienced programmers tend to write code with std::cout, std::string, etc., whereas less experienced programmers always write using namespace std;. They also tend to assume that, in code snips, it is already included.
Why is this? If it's a dislike, what's the problem with it? As stated in the namespaces tutorial on this site, a namespace can be overridden if need be. Is it the case that you have written your own namespaces? Or that you so seldom use things like the STL and stdin/out that it just isn't necessary?