Guidance using classes in C++
Not what you're looking for?
I am trying to learn about how to use classes with private and public variables in c++. I've got a conversion program that I would like to use as a prop.
If I was to add a class to this program, what I think I know is...
(Just to say, this is still fresh and I don't have a full grasp of all the concepts yet)
I know that to start a class, you must first declare it like for example...
class Conversion
{
private:
int inches;
int foot;
public:
void conversion(int happen);
};
Purchase this Solution
Solution Summary
This solution provides guidance for uses classes in C++.
Solution Preview
The attached code is in C++ and uses C++ class to convert foot and inches to Centimeters. It modifies the given program to accomplish this.
// 244228-classExample.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
class Conversion
{
// VARIABLE DECLARATIONS:
private:
float inches; // number of inches
float foot; //number of feet
float centimeters; // number of centimeters
public:
Conversion(){
inches = 0;
foot = 0;
centimeters = 0;
}
void convert();
float getInches();
void setInches(float in);
float getFoot();
void setFoot(float ft);
float getCentimeters();
void showOutput();
};
float Conversion::getInches(){
return inches;
}
void Conversion::setInches(float in){
inches = ...
Purchase this Solution
Free BrainMass Quizzes
C# variables and classes
This quiz contains questions about C# classes and variables.
Basic Computer Terms
We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.
Inserting and deleting in a linked list
This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.
Word 2010: Table of Contents
Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.
Word 2010: Tables
Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.