Click here to Skip to main content
15,886,199 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
SuggestionRe: SHA1- CheckSum Example in Microsoft Visual C++ 6.0 Pin
Peter_in_278014-Jun-16 16:53
professionalPeter_in_278014-Jun-16 16:53 
GeneralRe: SHA1- CheckSum Example in Microsoft Visual C++ 6.0 Pin
Member 1248511614-Jun-16 19:18
Member 1248511614-Jun-16 19:18 
GeneralRe: SHA1- CheckSum Example in Microsoft Visual C++ 6.0 Pin
Jochen Arndt14-Jun-16 21:19
professionalJochen Arndt14-Jun-16 21:19 
GeneralRe: SHA1- CheckSum Example in Microsoft Visual C++ 6.0 Pin
leon de boer15-Jun-16 4:11
leon de boer15-Jun-16 4:11 
GeneralRe: SHA1- CheckSum Example in Microsoft Visual C++ 6.0 Pin
David Crow15-Jun-16 1:53
David Crow15-Jun-16 1:53 
QuestionLarge project how to seprate definition and declaration? Pin
Hassan Syed112-Jun-16 9:47
Hassan Syed112-Jun-16 9:47 
AnswerRe: Large project how to seprate definition and declaration? Pin
leon de boer12-Jun-16 17:38
leon de boer12-Jun-16 17:38 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed112-Jun-16 18:34
Hassan Syed112-Jun-16 18:34 
Sir please check the following. There is something wrong. If you correct it for or highlight any improvement factor it will be appreciated.

Header File:

C++
#ifndef _CALCULATION_H
#define _CALCULATION_H
#include "calculation.cpp"
#include "getinput.cpp"

void input_Func(void); //Input function of text.
void input_Area(void); //Input function of Area.
void input_Trap(void); //Input function of Trapezoid.
float rectangle_Area (float , float); //Declaration for Rectangle Area.
float trapezoid_Area (float , float, float); //Declaration for Trapezoid Area.

#endif


Calculation File:

C++
#include "calculation.h"

//Calculation of Rectangle Area.
float rectangleArea (float width, float length)
{
    float Area_Rectange = 0;
    Area_Rectange = width * length;
    return (Area_Rectange);
}

//Calculation of Trapezoid Area.
float trapezoidArea (float base1, float base2, float height)
{
    float Area_Trapezoid = 0;
    Area_Trapezoid = ((base1 + base2)/2) * height;
    return (Area_Trapezoid);
}


Input data File:

C++
#include "calculation.h"

//Dealing with the input and output of data
void input_Func(void)
{
    cout << "\n\nEnter 1 to calculate the area of Rectangle" << endl;
    cout << "Enter 2 to calculate the area of a Trapezoid" << endl;
    cout << "\n\nEnter your choice : ";
    cin >> choice;
}

    //Dealing with input of Rectangle
    float input_Area(void)
    {
        float width = 0, length = 0, answer = 0;
        cout << "Enter the width of rectangle :";
        cin >> width;
        cout << "Enter the length of rectangle :";
        cin >> length;
        answer = rectangleArea(width, length);
        cout << "The area of Rectangle is : " << answer << endl;
        break;
    }

        //Dealing with input of Trapezoid.
        float input_Trap(void)
        {
            float base1 = 0, base2 = 0, height = 0, answer = 0;
            cout << "Enter base1 of trapezoid : ";
            cin >> base1;
            cout << "Enter base2 of trapezoid : ";
            cin >> base2;
            cout << "Enter the height of trapezoid : ";
            cin >> height;
            answer  = trapezoidArea(base1, base2, height);
            cout << "The area of Trapezoid is : " << answer << endl;
            break;
        }


Main File:
C++
/*
-------------------------
Name = Syed Sibt E Hassan
Registration Number = MC160201226
-------------------------
1) Input from the user
2) Function Calls
3) Exit when press 'N'
*/

#include <iostream>
#include "calculation.h"

using namespace std;

int main()
{
    int choice = 0;
    char tryagain = 0;
    do
            input_Func();

            switch(choice)
            {
            case 1:
                {
                    input_Area(); //Get Input of values for Rectangle
                    rectangle_Area (float , float);
                }
            case 2:
                {
                    input_Trap(); //Get Input of Values for Trapezoid
                    trapezoid_Area(float, float, float);
                }
            default:{
                cout << "Neither 1 nor 2 entered." << endl;
                }
            }

            cout << "Do you want to do another calculation? : ";
            cin >> tryagain;
        }while (tryagain == 'Y' || tryagain == 'y');

    return 0;
}


Your help to me in right direction will help me to become a good developer in future. I am completely new in this field. My code is working fine if i put everything in main function. Problem is arising when i am separating declaration and definitions Frown | :(
GeneralRe: Large project how to seprate definition and declaration? Pin
Jochen Arndt12-Jun-16 21:47
professionalJochen Arndt12-Jun-16 21:47 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer12-Jun-16 22:37
leon de boer12-Jun-16 22:37 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed113-Jun-16 1:25
Hassan Syed113-Jun-16 1:25 
GeneralRe: Large project how to seprate definition and declaration? Pin
Richard MacCutchan13-Jun-16 1:46
mveRichard MacCutchan13-Jun-16 1:46 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer13-Jun-16 4:03
leon de boer13-Jun-16 4:03 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed113-Jun-16 4:54
Hassan Syed113-Jun-16 4:54 
SuggestionRe: Large project how to seprate definition and declaration? Pin
David Crow13-Jun-16 5:23
David Crow13-Jun-16 5:23 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer13-Jun-16 16:19
leon de boer13-Jun-16 16:19 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed113-Jun-16 19:47
Hassan Syed113-Jun-16 19:47 
AnswerRe: Large project how to seprate definition and declaration? Pin
David Crow14-Jun-16 2:47
David Crow14-Jun-16 2:47 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer14-Jun-16 6:06
leon de boer14-Jun-16 6:06 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer14-Jun-16 10:01
leon de boer14-Jun-16 10:01 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed114-Jun-16 20:34
Hassan Syed114-Jun-16 20:34 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer15-Jun-16 3:53
leon de boer15-Jun-16 3:53 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed115-Jun-16 4:32
Hassan Syed115-Jun-16 4:32 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer15-Jun-16 6:21
leon de boer15-Jun-16 6:21 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed115-Jun-16 7:01
Hassan Syed115-Jun-16 7:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.