I have an array of (Student)classes created in Manager.h, which contains a new instance of class Name (name),(in Student.h)How would I go about accessing the SetFirstName method in Name.cpp if I was in a class Manager.cpp? I have tried using Students[i].name.SetFirstName("name");
// In Manager.h
#include"Student.h"
class Manager
{
Code: class RaspberryPi: public Singleton<RaspberryPi> { private: static const DeviceInfo GPS; template<typename Register_t> auto ReadGPS(Register_t& Register) -> void
[Code] ....
There are two limitations I am facing:
First, it seems that anything that is part of a struct cannot be a compile-time expression. It's a nice way to group information, so it would be nice to have.
Secondly, it seems that all compile-time expressions cannot be inside a class (at least according to VC++), which means I have to move them to global level, but while it can be done, I don't really want to do it, because it's a platform detail.
In this case, static type dispatch would be nice to have because I have a function
There are two types of registers. With runtime dispatch, I get disgusting errors such as "could not deduce template arguments, blah blah" if some object doesn't have the required interface (i.e., don't have overloads for both register types). So the workaround would be to add two overloads and use something like asserts to stop invalid code from running, but it would be so nice to only allow correct code to compile and not get scary error messages.
This is a program I developed in which we had to define a class named BOOK with the data members and member functions as shown in the program..We have to:
(i) Make the user enter the values in the array BOOK. (ii) Display the details that the user entered. (iii) Search for a book from the array upon its Bno and display its details. (iv) Search for a book from the array upon its Bname and display its details.
PROGRAM:
#include<iostream.h> #include<conio.h> #include<stdio.h> #include<string.h> class BOOK { private: int Bno; char Bname[20];
[Code] .....
But while running it the compiler gives the errors as:
Line 43 to 48: Illegal character '' (0x5c) Line 69: Undefined symbol 'Display' Line 88: 'BOOK::Bno' is not accessible. Line 89:'BOOK::Bname' is not accessible. Line 90:'BOOK::Author' is not accesible. Line 91:'BOOK::Price' is not accesible. Line 108:'BOOK::Bno' is not accessible. Line 109:'BOOK::Bname' is not accessible. Line 110:'BOOK::Author' is not accesible. Line 111:'BOOK::Price' is not accesible. from 43 to 48..the line feed was also used at many other places but there it was not given as an error so why here? Line 69: I defined the Display() function outside the class since it contained control structures, so what's the error then?
About the lines the rest of the error( the "not accessible" ones) I know these data members are not accessible because they are in private visibility mode. But then how to make them accessible? (Without putting them in public because it was a part of the question to create the data members in private).
I have two classes, a Package class and a Person class. The Package class has two Person objects has member variables, a Sender and a Receiver. While overloading the << operator for the Package class so that it will make an output label from everything in the Package class. Here is my code...
class Package{ public: Person Sender; Person Reciever; int weight; double cost; friend ostream &operator<<(ostream &out, Package &pack);
[Code] .....
So my problem is on that last output line, I am unable to call Sender.getName()... etc. Is there a proper syntax so that I can access the members of the Person class while overloading the << operator for the Package class?
I have a base class Building. Then come its children classes - Commercial Building and Residential Building. The third level is composed of Apartment and House classes, both inherit from Residential Building.
I need to create an array of 20 elements that will store info about all these different types of buildings(Commercial Building,Residential Building,Apartment, House). How should I proceed?
How to solve this because i was not able to get the idea of using arrays in classes . Here is the Question :
The PVR Cinemas manager approaches you to develop a system for ticket booking. It has 5 screens each with a capacity of 500 seats of which 100 are platinum, 100 are diamond and 300 are gold. The cost of platinum, diamond and gold tickets are Rs.150, Rs.125, and Rs.100 respectively.
•Construct a class to model a screen with an array of integers for each category of seats. Provide a constructor to initialize the array to 0. •Include a member function bookSeat() that gets the category of the seat and number of tickets to be booked and then prints the seat numbers. The booked seats are marked by 1. If no seats are available then your program should display appropriate message.
Test the above class with a main program that creates an array of objects (size of array depends on the number of screens) and display the total amount to be paid by the visitor.
I am currently trying to write a program, which i able to print a multidimensional array using classes. My problem is, it prints random values, and not the value from the user input.
In this program the intention is to create a menu driven program for a pizza restaurant. I have to use a class called Pizza and have to include at least three public functions; one is called SetSize, another one is called Display, and the last one is called ComputePrice. A small pizza is worth $10, a medium is $14, and a large is $17. Each topping is worth 2 dollars. I know that the program runs correctly, but I have doubts over the classes and function actually being utilized correctly or at all.
Program:
#include <iostream> #include <iomanip> #include <cmath> using namespace std; class Pizza { private:
I'm trying to use multiset with a user defined class "edge". I'm trying to use the multiset as a priority queue, and I've created a "less<edge>" via operator<() overloading.
For some reason, I cannot insert edges into the multiset.
I understand that I might also have to create an "allocator". I got some ideas for creating it at [URL], but still don't know how to define size_type and difference_type.
Attached is my skeleton code, running on Windows 7 (32-bit), under Netbeans IDE, using Cygwin g++ 4.7.3.
How can I get this to work? What is important is that I get a priority queue working with my edges, prioritized by the weight.
#include <iostream> #include <set> // for multiset using namespace std; // assume std libraries (i.e. std::XXX) class edge { // node, weight pair public:
I've created a base DLL for all my future DLL's, a way of getting version numbers and such and that compiles fine, but I can't add it into a class for a new DLL. All the headers do have an appropriate cpp to define the function declarations (and they compile fine).
im creating an address book. One address book contains a ListBox, New User button, Edit User and Remove User button. The first form is suppose to allow you to view the users you've created on the ListBox and you can decide whether you want to remove it, create a new one or simply edit the user. Now The second form simply contains labels and textbox along with a save button. I'm having a bit of issue figuring out the ListBox. I want to be able to create a user and have the user be posted on the ListBox. I read that i must instantiate listbox then simply add it. Now on my form2 i have a for loop that loops through an Array of String were all the users will be created on. How can i call that array of string on to the form1?
Form 1:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks;
[code].....
EDIT:I just figured out that to call a variable from one form to another you simply instantiate the form then simply call it. PS. must be set to public:
ListBox1 createUser = new ListBox1(); createUser.userString[0];
why doesnt it show the windows when i run without debugging?
-create a get and set for height, width, length. -A default parameterized constructor = 1 -A method to resize the box -A method to get the volume of the box -A method to convert the object to a string
My Questions:
The 3 parts I am confused by are the default parameter constructor, the re-size the box and the method to convert to string. For the default parameter part I figured making length, width and height = to 1 would work, but I'm pretty sure thats not what I'm supposed to do.
This is the main file
#include "box_class.h" #include <iostream> using namespace std; int main() { double length; double width; double height; double volume;
I am just wondering what the best practice is for when to use static classes (by static class, I mean a class which has only static attributes and functions).
If you are creating more than one independent object of a particular class, then obviously this should not be static because each object will be the same. But what about the case when you know that you will only ever need one instance of a class? On its own, does this mean that you should create it as a static class?
Personally, I use static class when I want its member attributes and functions to be available globally, which I think is fine. However, I am not sure about the case when I know that only one object will be created - should this be a static class or not?
I'm working on a project involving nested classes and structs like this:
Code: class A { public:class B { public:f() {A::C* iCanDoThis; //no errors. iCanAlsoDoThis->root->.... //this also works fine.}private:A::C* iCannotDoThis //this is what I would like to do. Has errors A* iCanAlsoDoThis;};private:struct C {..data..};
C* root;};
Is it possible make a pointer to struct C a private member of class B?
I have a hpp file with a list of inline finctions like this:
Code: inline int check() { return 1; } inline int check_1() { return 1; }
... What I would like to do is to include them into several unrelated classes. How can I do this. Can I just add the hpp inline functions in headers of my class containing files or not. I mean if they are not defined as class functions how can they be called. I don't understan the logic.
Is there a way to export a c++ class for another language. I need to find an interpreted language that can use c++ classes (actually just one class) exported in DLLs. It wouldn't surprise me if you couldn't though because of how classes are handled in c++. Maybe python could do it because it's object oriented uses something very similar to the "this" pointer.
If I have a static variable in a class e.g. a pointer to another class like this: (B is another class)
class A { public: static B* cB; };
Then I set that variable and create multiple instances of class A like this:
A::cB = new B; As = new A[Number];
Then will the value of cB be the same across all instances?
I cannot pass the class pointer in the constructor as I need to create an array of instances. I tried this method but I get linker error.... unresolved external.
I've written a doubly linked list per my assignment instructions. I've implemented begin() and end() iterators for it, and they work with no problems when traversing the list. However, I need to sort the elements in the list. We are allowed to use the sort function defined in the <algorithm> header since we haven't yet covered sorting algorithms.
But, I'm running into a ton of problems. I figured as long as the begin() and end() iterators were defined for the list, then sort(list.begin(), list.end(), compare) would do the trick. The main errors I'm getting are:
error: no type named iterator_category error: no type named value_type error: no type named difference_type error: no type named pointer error: no type named reference
And also errors for no match of the + and - operators for the iterator class.
I understand reference, pointer, and value_type, but I have no idea about iterator_category and difference_type. Additionally, I'm a little unsure why the + and - operators need to be overloaded.
Here's a few parts of a program I'm working at. It does compile, and it does work as expected. Anyway Eclipse Kepler marks one line as a bug with the remark Field 'befehl' could not be resolved. The bug sign didn't show up when both classes were in one file.
ScriptInterpreter maintains and processes a vector of Objects, initialised with example data. An iterator of the vector keeps track of the current position while various methods process the data. I've copied the relevant lines only.
I can live with a few wrongly bug-marked lines in Eclipse. What I don't want is any hidden errors that express at some time later.
Is there anything wrong with the code? Anything that's not recommended and compiles anyway? Is anything c++11-specific about the questionable line?
AtomicCommand.h class AtomicCommand { public: int befehl;
[Code] .....
Note that line 9 has a bug sign, too. Eclipse doesn't recognise all my c++11 code.
As long as no base class constructor takes any arguments, the derived class need not have any constructor, if one or more arguments are used then it is mandatory for the derived class to have a constructor and pass the arguments to base class constructors. While applying inheritance, we usually create objects using derived class. Then it makes sense for the derived class to pass arguments to the base class constructor. When both the base and derived class contain constructors ,the base class constructor is execute first.
In case of multiple inheritance, the base classes are constructed ,in the order in which they appear in the declaration of the derived class. Similarly in a multiple inheritance the constructors will be executed in order of inheritance. Since the derived class takes the responsibility to supply initial values to the base class,we supply the initial values that are required by all the classes together where the derived class object is declared.
The constructor of the derived class receives the entire list of values of arguments and pass them on to the base constructors int the order in which they are declared in the derived class
so i was trying to find out how to do unbuffered input in linux and came across this class: [URL] . i didnt like how i had to create a new instance of it each time i wanted to use it, so i made the functions static and renamed the class to Buffer. i could then call it like this: Buffer::On(); Buffer::Off();. My question is, when doing something like that where the class consists of two functions that can exist indepently of another, which is better: a class like what i did or wrapping it in a namespace?
I have 2 integers, both in 2 seperate classes in 2 seperate files. I have main.cpp, test_01.h, Test_01.cpp, Player.h and Player.cpp. I ahve a function which takes an integer (a) as a parameter (from Test_01.h and Test_01.cpp). a sets another integer (attackPower) from the same class equal to a. The integer (health) in the other class (Player.h and Player.cpp), is then equal to health -= attackPower. But instead of giving me the right answer 75 (health = 100 and a is set to 25 when i call the function) it gives me the answer.
main.cpp
#include <iostream> #include "Test_01.h" #include "Player.h" using namespace std; int main() { Player p; Test_01 t;
I want to write a program in cpp which will create a file and write some classes into it so that whenever i will execute that program i will have the auto generated file. How to do it....