C/C++ :: Showing Separate Lines For Objects?

Mar 31, 2014

#include<iostream>
#include<string>
using namespace std;
//Constructors for class.
class CollegeCourse {
private:
int courseNum;

[Code] ....

When I debug my program, the objects is showing up on one line bunched up together. I also want to be able to enter data after each object of the classes.

The details of my project is as follows:

Inheritance in C++ means you can create classes that derive their attributes from existing Classes, in other words, a newly created class can absorb all the data fields and functions of a class already being used. When one class is derived from another, the original class is the parent class, base class, or sometimes called the parent class. The derived class is a child class, or sometimes called the subclass.

Inheritance is central to Object Oriented Programming. The advantages of inheritance are it allows the code to be reused as many times as needed. Inheritance also saves time and effort as the main code need not be written again.

Create a C++ program using Visual program that could be used by a college to track its courses. In this program, create a CollegeCourse class includes fields representing department, course number, credit hours, and tuition. Create a child (sub class) class named LabCourse, that inherits all fields from the CollegeCourse class, includes one more field that holds a lab fee charged in addition to the tuition. Create appropriate functions for these classes, and write a main() function that instantiates and uses objects of each class.

View 1 Replies


ADVERTISEMENT

C/C++ :: How To Print Random Number Asterisks On Two Separate Lines

Apr 20, 2015

Im trying to figure out how to print a random number of asterisks on two separate lines at the same time. So every time you press a key it prints a different amount of random number of integers between1 and 10 until one of the lines reaches 70. I have the code to do one line but can't figure out how to do two at once.

#include <stdio.h>
#include <time.h>
#define MINR 1
#define MAXR 70
#define MINM 1
#define MAXM 10
int main (void)

[Code]...

View 2 Replies View Related

C++ :: Objects / Classes And Separate Compilation

Apr 9, 2013

Code:
class A
{
public:A(int a, int b);
};

I need to have an object of class A that doesn't have a default constructor in another class, B:

Code:
class A; //This is in a separate header file
class B
{
private:A a;};

The problem is that it won't compile without a default constructor. I'm not allowed to define a default constructor, and the A object in class B has to be private so I can't initialize A a in public.

I also can't change the prototype in the interface to something like

A(int a = 0, int b = 0);

since one of the requirements is that if an object of class A is declared in main, it must not compile due to not having a default constructor. So what can I do to make class B work and compile?

Another question I have is why is this valid:

Code:
class A; //#include "A.h" is in the implementation file so it compiles.
class B
{
private:A* a;}; But not this: Code: class A;

class B
{
private:A a;};

This is for a project that I probably won't be able to turn in on time, but I care more about how to do this right than turning it in for full points.

View 4 Replies View Related

C++ :: Read Story From Input File / Separate Words And Output Lines On Which The Word Occurs

Feb 21, 2014

I have program that is supposed to read in a story from an input file and separate the words and output the lines on which the word occurs. It needs to read in another input file that has a list of words (1 per line) to ignore. i.e. skip them when running through the story. This is what I have so far, I've changed multiple things trying to get it running....

#include<iostream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<string>
#include"split.h"

[Code] .....

View 1 Replies View Related

C++ :: SDL Font Not Showing

Jan 19, 2013

SLD_ttf lib and I have been following the Lazy Foo' tuts on it but the text is not appearing. I have found out that it is not loading the font as I have added in the code saying if it has failed.

Code:

font = TTF_OpenFont( "lazy.ttf", 28 );
if( font == NULL )
{
return false;
}

i have saved this font in the project (project name/project name/lazy.ttf).

View 19 Replies View Related

C++ :: Image Not Showing On Top

Jul 1, 2013

I am trying to display images on top of my Background image gui, so like buttons an stuff but the problem is that there not showing ontop. I can only get one of them to show

// includes
#include <windows.h>
#include <stdio.h>
#include "res.h"

// defines
#define LWA_COLORKEY 0x00000001
#define LWA_ALPHA 0x00000002

[Code] ....

View 1 Replies View Related

C/C++ :: Objects Hold References To Other Objects?

Nov 12, 2014

This has been bothering me for a while now, and I finally put together an example:

#include <iostream>
#include <string>
using namespace::std;

[Code]....

In the code above, the two classes hold pointers to each other, and that's fine but it doesn't seem right since C++ prefers to pass by reference. Yes, it can still do that (see testbox and testball) but even that seems odd to me because still you need to use pointer notation for the enclosed object. Am I the only one who feels this way, and should I just get over it? Or am I missing something that would allow an object to hold a reference?

View 4 Replies View Related

C++ :: Output Is Showing Address Instead Of Value

Dec 7, 2013

I've run across this issue before, but for the like of me, I can't figure out what keeps causing it. The problem compiles and runs as expected; however in the salaried object (Employee #1 in main.cpp) the console displays the number of vacation days as -858993460 instead of the value entered.

The parent Employee class is abstract with calculatePay() and displayEmployee() being pure virtualls and with a Benefits, Salaried, and Hourly class derived from it.

The Salaried displayEmployee() and the portion of the Main.cpp that contains the salaried object follows. What causing this?

Salaried displayEmployee()
Code:
void Salaried::displayEmployee()
{
cout << endl;
cout << "Employee Information" << endl;
cout << "----------------------------------" << endl;
cout << "Employee Name: " << setw(7) << FirstName << " " << LastName << endl;
cout << "Gender: " << setw(12) << Gender << endl;

[Code] .....

View 2 Replies View Related

C :: Float Showing Nothing In Printf

Oct 6, 2014

I just checking but confused with float. in that code same size int, and same type double are working but float showing nothing in printf..why?? i'm using GCC compiler int 32bit win7 os

Code:
#‎include <stdio.h>
int main() {
char arr[10] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
printf("Size of char=%c
", ((char *) (&arr[0]))[1]);

[Code] ....

View 14 Replies View Related

C :: Calculating And Showing RPM On Display

Feb 19, 2014

As part of a project i want to display the speed of a small wheel on a 7 segment display. I am using a hall effect sensor to pick up the pulses of the rotation. I am not sure how to write a programe on C to calculate the RPM from this....

View 4 Replies View Related

C++ :: Calculations Are Done Correctly But Showing Zero

Nov 26, 2013

#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;

[Code] ....

View 1 Replies View Related

C/C++ :: Showing The First Digit Of Zip Code?

Nov 21, 2014

My question is why my on my code there is 10 zip code and i want to show the first digit, the problem is the first digit does not match the zip code for example the zip code is 45805 it should be '5' however, my code shows other number!

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

[Code].....

View 4 Replies View Related

C++ :: CPP File Not Showing Code

Nov 19, 2013

i have been making code of a chessgame and now sddenly computer freezed and now there's not code in .cpp file! Although my .cpp file shows size of 16kb but when i open it . there's nothing except bank file

View 1 Replies View Related

C++ :: Tic Tac Toe - Board Is Not Showing Numbers

Feb 7, 2014

I'm programming tic tac toe but the board is not showing numbers, and it is simply stating the winner without any input: (the win conditions are not complete, but it shouldn't matter).

#include <iostream>
#include<string>
using namespace std;
//Write a two-player tic-tac-toe game; use enums when possible to represent the values of the board

char ticBoard[3][3];
char board[10];
void showBoard();
bool moveIsValid(int m);
int whoWon(); // 0 tied, 1 p1, 2 p.2

[Code] ....

View 6 Replies View Related

C# :: Variable Showing As Not Instanced

Oct 19, 2014

I'm receiving an error that an array has not been initialized but I'm not quite sure why. Also, I realize a list may be better in this scenario but I would still like to know what I'm doing wrong.

Warning in the IDE

Warning3Field 'Routines.SvrMain.Servers' is never assigned to, and will always have its default value nullD:Google DriveCodingC# ProjectsNONameWindowsFormsApplication1WindowsFormsApplication1Routines.cs26638WindowsFormsApplication1

Error that pops on line
Servers[Index].Address = Parser.ReturnAddress(); //returns an IPAddress

Object reference not set to an instance error

ServerDetails Class
public class ServerDetails {
public IPAddress Address; { get; set; }
public int Port { get; set; }
}

[Code] ....

View 12 Replies View Related

C/C++ :: Why Invalid Letter Not Showing

Feb 29, 2012

I wanna know why the program doesnt show "Invalid Letter Entered" when i enter any letter other than A S D or M

//Processing the data
    if (letter== 'A'||'S'||'M'||'D')// checking Add, subtract, multiply or divide {
        if (letter== 'A')//Adding the integers
            cout<<"Adding two integers = "<<first + second<<endl;
        else if (letter== 'S')//Subtracting the integers  {

[code]......

View 1 Replies View Related

C++ :: Input Showing As Default Values?

Nov 30, 2013

Same solution that I was having compiler errors on yesterday. We're working with inheritance and the program is supposed to be to create and display information for default Employee objects, Hourly Employee objects and Salaried Employee objects. Everything compiles as is, but I'm running into two issues that I can't figure out.

1) In both the hourly and salaried objects, the wage, hours, and management level attributes all displaying their default values. I'm almost positive that this has something to do with the str to int and str to double conversions that I'm using (currently have atoi and atof in the file, but I've also tried stringstream, but still had to same problem). Any thoughts as to what I'm missing?

2) the assignment calls for the Benefit benefit member in Employee.h to be protected. However this makes the member unaccessible when I try to use it in the EmployeeMain.cpp in order to set the input for the Benefit class members. I had to make the Benefit benefit member public again to get it to compile. How would I set the input for the Benefit class members while the Benefit benefit member is protected?

Solution files follow:

EmployeeMain.cpp
Code:
#include "Hourly.h"
#include "Salaried.h"
void DisplayApplicationInformation();
void DisplayDivider(string);
string GetInput(string);

[Code]....

View 3 Replies View Related

C++ :: Fees Showing Up Wrong On Program

Feb 19, 2014

I'm writing a program that shows check fees for different amounts of checks. My other fees are showing up right but the .10 cents is not. It's showing up as .08 cents per check when I run the program.

Oh yeah the + 10 is for a $10 fee

Code:
else if (checks < 20 || checks >= 0) {
fee = .10 * checks + 10;
cout<< "Bank service charge for the month is $ " << setprecision(4) << endl;
}

View 3 Replies View Related

C :: Multi Character Is Showing Error

Mar 26, 2014

When i am entering single character instead of 'miz' then it is working great. But when i am using multi character like 'miz' it is showing error output. i did this program with c++ it is working but not working in c.When i am running this program it is showing {warning] multi character constant.

Code:

#include<stdio.h>
#include<string.h>
main()
{
char a;
printf("Please Enter your First Name: ");
scanf("%s",&a);

[Code]....

View 1 Replies View Related

C++ :: Allegro Sprite Is Not Showing Up In Right Spot

Jun 8, 2013

So I have a small game I'm making using OOP principles, I know it's a little bit of overkill but it's just for educational purposes. I have a sprite character that can be moved around with no problems, but I made a sword for him as a separate sprite that doesn't follow him. The sword sprite is supposed to cover his arm and his body as it swings, but it just stays in the upper left corner.

I messed around with the initialization of the sword in the main.cpp and I changed in sword.cpp and sword.h and it still is showing up in the same place. I even looked at the GetX() and GetY() statements I made and they seemed to work fine and when I debugged it, the variable values showed up correctly, but the sword doesn't move.

View 3 Replies View Related

C++ :: Showing Data Added To Classes

Feb 15, 2014

I am new to using classes, and am running into an issue already. I have created the class, and am in the process of adding data to the classes. I have added one piece of data, and now just want to see if I can get it to show in another function, but I am not sure why it is not showing. What about getting the data to show. Then, I will be able to work on adding the rest of the info.

#include <iostream>
#include <cctype>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
//******************************Bill Class**************************
class bill {

[Code] ....

FYI - This is only the relevant code. There is more for this that I have not added.

Error #1: error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

Error #2: error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

View 2 Replies View Related

C/C++ :: Line Of Constructor Is Showing Error

Mar 17, 2014

#include <iostream>
using namespace std;
class qwerty{  
    public:
    qwerty();
    void dispalymessage(){

[Code] ....

why am i getting an error in the qwerty() line when i run the program?if i remove qwerty() then the program is runing fine...y this is happening so?

View 2 Replies View Related

C/C++ :: Showing Multiple Web Pages With ShellExecute?

Mar 16, 2014

I have function like this:

void OpenURL(LPWSTR url) {
//Notice! 6 parameters, not 7
ShellExecute(NULL, L"open", url, NULL, NULL, NULL);
}  

If I then use this function like this:

OpenURL(L"http://www.google.com/");
OpenURL(L"http://bytes.com/");
OpenURL(L"http://www.yahoo.com/");  

sometimes only the first web page is opened, but sometimes all of them. What I should do so that all the web pages opened with OpenURL-function are always opened? Also, better ways to open web pages are very welcome. I use Visual Studio 2008 Express and Visual Studio 2013 Express.

View 4 Replies View Related

Visual C++ :: Showing Row And Column Totals?

Apr 24, 2013

Trying to show the Row totals and the Column totals.

#include <stdio.h>
int main() {
/* start of main */
#define NUMROWS 5 /* establishes NUMROWS as 5 */
#define NUMCOLS 5 /* establishes NUMCOLS as 5 */
int val[NUMROWS][NUMCOLS] = { {23,06,85,22,01}, /* declares array val to have 5 rows and 5 columns */
{07,33,62,17,04},

[Code] ....

I receive this message after building:

1>------ Build started: Project: WA 4 A 1 Christopher Caron, Configuration: Debug Win32 ------
1> WA 4 A 1 Christopher Caron.cpp
1>c:userschrisdocumentsvisual studio 2010projectswa 4 christopher caronwa 4 christopher caronwa 4 a 1 christopher caron.cpp(21): error C2106: '=' : left operand must be l-value

[Code] .....

View 2 Replies View Related

C :: Can Play Audio Without Extra Window Showing?

Jul 7, 2013

I got this code from a wiki that taught me how to make C code that plays audio, and with a few changes I was able to get it to take a command-line argument as the music file name. Here it is

Code:
#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>

int main(int argc, char *argv[])

[Code] ....

The only problem is, even though I guess it needs to create a window to work with SDL, is there any way you could hide it or something so the user can't see it? I don't really want to see it ( I'm planning on running it from Batch files or C applications as an easy way to play an audio file once ), because if I did, I might as well just use a default audio player instead.

View 3 Replies View Related

C++ :: How To Get List Of Applications Showing By Task Manager Through API

Oct 21, 2014

I am searching for a way/api through which i can get list of Applications as showing by task manager inside Applications tab. Is there any way?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved