I am learning C++. It is going really well. It is making other stuff I have done in programming really make sense. I was interested in getting started programming with C++ visually. I want to make a program that runs on Windows. I did not know where to get started. There is not a lot of info on the topic. I found a helpful video on YouTube that showed how to get set up. It leaves me off with code like so:
I do not know how to continue from here. How would I add some code that performs something like calculating with overloaded functions! If anybody has any examples I would greatly apreciate seeing them. I want to make a program that calculates values for a sphere or a cylinder with an overloaded function like so:
in func.h:
The video I watched is:
https://www.youtube.com/watch?reload=9&v=0XGQIN9hfGQ
Thanks for any help
Code:
#include "MyForm.h"
using namespace System;
using namespace System::Windows::Forms;
[STAThreadAttribute]
int main(array<String^>^ args) {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Lotto1::MyForm form;
Application::Run(%form);
return 0;
}
Code:
int main()
{
double Pi = 3.14790;
cout << "Enter a radius: ";
double radius = 0;
cin >> radius;
cout << "The sphere = " << calcRound(Pi, radius) << endl;
cout << "Do you want to calculate the a cylinder? (yes = y/no = n) ";
char answer1 = 'n';
cin >> answer1;
if (answer1 == 'y')
{
cout << "Enter a height: ";
int height = 0;
cin >> height;
calcRound(Pi, radius, height);
cout << "The cylinder = " << calcRound(Pi, radius, height) << endl;
}
return 0;
}
double calcRound(double Pi, double radius)
{
Pi = 3.1409316;
double sphere = 4 * Pi * radius * radius * radius;
return sphere;
}
double calcRound(double Pi, double radius, int height)
{
Pi = 3.14317529;
double cylinder = Pi * radius * radius * height;
return cylinder;
}
Code:
in func.h:
#ifndef FUNC_H_
#define FUNC_H_
double calcRound(double Pi, double radius);
double calcRound(double Pi, double radius, int height);
#endif // FUNC_H_
https://www.youtube.com/watch?reload=9&v=0XGQIN9hfGQ
Thanks for any help