*

Offline beardo

  • *
  • Posts: 4501
    • View Profile
Re: C++
« Reply #20 on: January 27, 2014, 01:40:42 PM »
What's the difference between C and C++?
The Mastery.

*

Offline Parsifal

  • Administrator
  • *****
  • Posts: 5633
  • Professional computer somebody
    • View Profile
Re: C++
« Reply #21 on: January 27, 2014, 01:57:48 PM »
What's the difference between C and C++?

C++ is a poor imitation of OOP hacked on top of C.
when you try to mock anyone while also running the flat earth society. Lol

Re: C++
« Reply #22 on: January 27, 2014, 02:28:41 PM »
What's the difference between C and C++?

C++ is a poor imitation of OOP hacked on top of C.

Basically this.
But for more specifics, C++ allows for objects.  What's an object?  Its a collection of variables and data that describe something.  For example: the post button is an object.  It has an image, width, height, alt text, and functions like mouse over (when you hover your mouse over it) and click.  All these bits are different types of data used to create one thing.



I recommend VB(Visual studio has Visual Basic in it) because its an object oriented language, its as easy as a scripting language, and it's forgiving. 
Its a good starter to understand basic logic and coding.  But you can't do much in the way of fancy things nor is it efficient in its compiled code.

*

Offline spoon

  • *
  • Posts: 1132
  • Foxy wins
    • View Profile
Re: C++
« Reply #23 on: January 30, 2014, 12:20:38 AM »
Well, I have run into my first roadblcok. I am getting this error message when I try to build:

error C4430: missing type specifier - int assumed.

It doesn't highlight any errors in my code, but it directs me to the line where I have my first squiggle bracket. Prior to the bracket I add the directives I need to and name the program (not sure if this is the correct language). I add the bracket then I start my code on the next line. Why is it directing me to this line? Based on the error, it seems as if I didn't specify my variable types. However, I declared every variable as "double". I had six variables and two constants, which I also declared as double. I am not too sure where I made my mistake. Would I need to post the code or does anybody have an idea where I am at fault?
inb4 Blanko spoons a literally pizza

Re: C++
« Reply #24 on: January 30, 2014, 01:08:00 AM »
Post the code.

*

Offline spoon

  • *
  • Posts: 1132
  • Foxy wins
    • View Profile
Re: C++
« Reply #25 on: January 30, 2014, 01:17:59 AM »
#include <iostream>
#include <cmath>

using namespace std;

main()
{
   double Angle;
   double IVelocity;
   double HorVelocity;
   double VertVelocity;
   double Time;
   double HorDist;
   const double PI = 3.14159265;
   const double Accel = 9.8;

   cout << "The object's initial flight angle above horizontal is ";
      
      cin >> Angle;

   cout << "The initial velocity of the object is ";
   
      cin >> IVelocity;
   
   VertVelocity = IVelocity * sin(Angle * PI / 180);
   HorVelocity = IVelocity * cos(Angle * PI / 180);
   Time = VertVelocity / Accel;
   
   HorDist= HorVelocity * Time;

   cout << "The horizontal distance travelled by the object is " << HorDist;

system( "pause" );
return 0;

}

I realize this might not be organized well. Remember, i m nub.
inb4 Blanko spoons a literally pizza

*

Offline spoon

  • *
  • Posts: 1132
  • Foxy wins
    • View Profile
Re: C++
« Reply #26 on: January 30, 2014, 01:19:00 AM »
btw, we are modelling projectile motion, if that isn't clear.

Also, this is my first guess at how to do this. I could be completely wrong.
« Last Edit: January 30, 2014, 01:21:30 AM by spoon »
inb4 Blanko spoons a literally pizza

Re: C++
« Reply #27 on: January 30, 2014, 01:58:28 AM »
I'm out of the loop on C++ but ... Pretty sure you need "int main()" if you're going to return an integer.

In fact, take out the 0 in the return and see if that fixes it.

*

Offline spoon

  • *
  • Posts: 1132
  • Foxy wins
    • View Profile
Re: C++
« Reply #28 on: January 30, 2014, 02:01:18 AM »
I'm an idiot. "int main()" fixed it. Thanks haha

inb4 Blanko spoons a literally pizza

*

Offline beardo

  • *
  • Posts: 4501
    • View Profile
Re: C++
« Reply #29 on: January 30, 2014, 05:25:49 AM »
#include <iostream>
#include <cmath>

using namespace std;

main()
{
   double Angle;
   double IVelocity;
   double HorVelocity;
   double VertVelocity;
   double Time;
   double HorDist;
   const double PI = 3.14159265;
   const double Accel = 9.8;

   cout << "The object's initial flight angle above horizontal is ";
      
      cin >> Angle;

   cout << "The initial velocity of the object is ";
   
      cin >> IVelocity;
   
   VertVelocity = IVelocity * sin(Angle * PI / 180);
   HorVelocity = IVelocity * cos(Angle * PI / 180);
   Time = VertVelocity / Accel;
   
   HorDist= HorVelocity * Time;

   cout << "The horizontal distance travelled by the object is " << HorDist;

system( "pause" );
return 0;

}

I realize this might not be organized well. Remember, i m nub.
Gibberish.
The Mastery.

*

Offline Parsifal

  • Administrator
  • *****
  • Posts: 5633
  • Professional computer somebody
    • View Profile
Re: C++
« Reply #30 on: January 30, 2014, 06:01:58 AM »
Thanks for posting that and reminding me why I hate C++.
when you try to mock anyone while also running the flat earth society. Lol

*

Offline beardo

  • *
  • Posts: 4501
    • View Profile
Re: C++
« Reply #31 on: January 30, 2014, 06:27:42 AM »
What would the equivalent code in C look like?
The Mastery.

*

Offline Parsifal

  • Administrator
  • *****
  • Posts: 5633
  • Professional computer somebody
    • View Profile
Re: C++
« Reply #32 on: January 30, 2014, 06:33:13 AM »
What would the equivalent code in C look like?

I'll translate it when I get home. It's mostly similar, except that C doesn't pretend to be OOP.
when you try to mock anyone while also running the flat earth society. Lol

*

Offline Pete Svarrior

  • e
  • Planar Moderator
  • *****
  • Posts: 9945
  • (>^_^)> it's propaganda time (◕‿◕✿)
    • View Profile
    • The Flat Earth Society
Re: C++
« Reply #33 on: January 30, 2014, 08:18:42 AM »
I'll translate it when I get home. It's mostly similar, except that C doesn't pretend to be OOP.
Given that the code posted doesn't even attempt to use objects*, I struggle to think what you're on about.

I'm out of the loop on C++ but ... Pretty sure you need "int main()" if you're going to return an integer.

In fact, take out the 0 in the return and see if that fixes it.
In C++, main() has to be defined as returning an int. Also, if you wanted to define a function that returns nothing, just saying stuff() would be incorrect. What you'd need is void stuff(). Also, you should never advise people for their C(++) programs to do anything else than return 0 (or EXIT_SUCCESS, which is technically better) at the end of their successfully-executed programs.

What would the equivalent code in C look like?
It would use printf() or puts() instead of cout, and scanf() or gets() instead of cin. The code would flow pretty much the same, and Parsifal is just being a massive gays.

* - inb4 Parsifal points out that cin and cout are technically objects.
« Last Edit: January 30, 2014, 08:33:04 AM by pizaaplanet »
Read the FAQ before asking your question - chances are we've already addressed it.
Follow the Flat Earth Society on Twitter and Facebook!


*mic stays stationary and earth accelerates upwards towards it*

Re: C++
« Reply #34 on: January 30, 2014, 10:45:08 AM »
I'm out of the loop on C++ but ... Pretty sure you need "int main()" if you're going to return an integer.

In fact, take out the 0 in the return and see if that fixes it.
In C++, main() has to be defined as returning an int. Also, if you wanted to define a function that returns nothing, just saying stuff() would be incorrect. What you'd need is void stuff(). Also, you should never advise people for their C(++) programs to do anything else than return 0 (or EXIT_SUCCESS, which is technically better) at the end of their successfully-executed programs.

Ah yes. Thank you.

*

Offline spoon

  • *
  • Posts: 1132
  • Foxy wins
    • View Profile
Re: C++
« Reply #35 on: June 04, 2014, 05:46:27 PM »
I downloaded a library called PNGwriter. I would like to use it, but I am clueless as to how I would go about doing that in visual studio.

I know that I would need to #include the library, but I don't really know how to do that. Any insight would be appreciated.
inb4 Blanko spoons a literally pizza

*

Offline spoon

  • *
  • Posts: 1132
  • Foxy wins
    • View Profile
Re: C++
« Reply #36 on: June 04, 2014, 05:49:26 PM »
Further research tells me it's not exactly easy to do on windows. ugh

Basically, what I want to do is take the output from my code and format it on a png file. halp.
« Last Edit: June 04, 2014, 05:56:14 PM by spoon »
inb4 Blanko spoons a literally pizza

*

Offline Pete Svarrior

  • e
  • Planar Moderator
  • *****
  • Posts: 9945
  • (>^_^)> it's propaganda time (◕‿◕✿)
    • View Profile
    • The Flat Earth Society
Re: C++
« Reply #37 on: June 04, 2014, 06:17:58 PM »
Basically, what I want to do is take the output from my code and format it on a png file. halp.
It seems like you already found a library that does that. Now you just need to stop whining that computers are hard and start actually using it.

As for figuring out how to link libraries in Visual Studio - I haven't worked with VS in ages, so I can't really guide you, but I just gave you all the keywords you need for your Google search to work.
Read the FAQ before asking your question - chances are we've already addressed it.
Follow the Flat Earth Society on Twitter and Facebook!


*mic stays stationary and earth accelerates upwards towards it*

Re: C++
« Reply #38 on: June 04, 2014, 06:28:59 PM »
Well, I have run into my first roadblcok. I am getting this error message when I try to build:

error C4430: missing type specifier - int assumed.

This is telling you that you are missing a type a type identifier.

*

Offline spoon

  • *
  • Posts: 1132
  • Foxy wins
    • View Profile
Re: C++
« Reply #39 on: June 04, 2014, 07:27:06 PM »
Basically, what I want to do is take the output from my code and format it on a png file. halp.
It seems like you already found a library that does that. Now you just need to stop whining that computers are hard and start actually using it.

As for figuring out how to link libraries in Visual Studio - I haven't worked with VS in ages, so I can't really guide you, but I just gave you all the keywords you need for your Google search to work.

nah it's too hard

I just converted it to a word doc lol
inb4 Blanko spoons a literally pizza