Click here to Skip to main content
15,881,455 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
Okay so this is your Calculation.h file ... which is only changed by removing the two include which are not needed
#ifndef _CALCULATION_H
#define _CALCULATION_H

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


So now you must provide all that in a Calculation.cpp file which would be all the code below.
So here are the functions you provided but notice I have marked the errors on the 2 functions Input_Area & Input_Trap
So currently only 3 of your 5 functions are correct
#include "calculation.h"   // include you header file 

//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);
}

//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;
}

// YOU HAVE SERIOUS ERRORS IN THE TWO FUNCTION CODES BELOW

//Dealing with input of Rectangle
float input_Area(void)  // *** ERROR *** YOUR HEADER HEADER FILE IS ==== > void input_Area(void);  WHICH IS IT THEY MUST MATCH??????
{
   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;  // <<==== ***** ERROR ***** WHAT ARE YOU BREAKING FROM
   
   /// ***** ERROR *****
   // There is another problem here you have not returned anything 
   // You declare you are going to return a float and don't ..  You put this === > float input_Area(void)
   //
   // I think you may want to return the variable Answer but your code matches
   // the header file returning nothing so I am confused what you are doing
   //
   // You need to be clear are you returning a float or not and fix it
}
 
//Dealing with input of Trapezoid.
float input_Trap(void)    // *** ERROR *** YOUR HEADER HEADER FILE IS ==== > void input_Trap(void);  WHICH IS IT THEY MUST MATCH ??????
{
   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;  // <<==== ***** ERROR ***** WHAT ARE YOU BREAKING FROM
   
   /// ***** ERROR *****
   // There is another problem here you have not returned anything
   // You declare you are going to return a float and don't .. You put this === > float input_Trap(void)
   //
   // I think you may want to return the variable Answer but your code matches
   // the header file returning nothing so I am confused what you are doing
   //
   // You need to be clear are you returning a float or not and fix it
}


You main file is correct in that it just includes calculation.h
In vino veritas


modified 13-Jun-16 10:10am.

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 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer15-Jun-16 8:04
leon de boer15-Jun-16 8:04 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed115-Jun-16 8:48
Hassan Syed115-Jun-16 8:48 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer15-Jun-16 20:00
leon de boer15-Jun-16 20:00 
QuestionGlut errors with Mingw on windows Pin
Ratul Thakur11-Jun-16 7:03
Ratul Thakur11-Jun-16 7:03 
AnswerRe: Glut errors with Mingw on windows Pin
Ratul Thakur11-Jun-16 20:02
Ratul Thakur11-Jun-16 20:02 

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.