Graalians

Graalians (https://www.graalians.com/forums/index.php)
-   Technology (https://www.graalians.com/forums/forumdisplay.php?f=54)
-   -   Coding in C++ (https://www.graalians.com/forums/showthread.php?t=26365)

hosler 02-24-2015 09:35 PM

Reports are important for things

Motrox 02-25-2015 01:30 AM

I'll be posting again shortly.
I've been really busy lately so I haven't been able to code very much.

Grief Hero 02-25-2015 05:23 PM

l33t c0der

Zachary 04-18-2015 11:11 AM

Quote:

Posted by Jatz (Post 520752)
C++ is the lowest level of the the languages (Closest to machine code) because it forces you to manage your own memory. It has the concept of pointers, while Java & Javascript do not, using references instead. C++ is static typed & follows C-Style syntax.

Wrong. Assembly is lower-leveled than C++ and higher-leveled than machine language. C++ is actually compiled into assembly.

Quote:

Posted by Tricxta (Post 522475)
Start learning about object oriented(OO) concepts like polymorphism and inheritance. You can practice both using the following exercise.

Consider a list that can store multiple types of shapes.

Using this one list, store a square, triangle and circle. Iterate over that list and print out the area and name of each shape.
Example pseudocode of populating such a list might be

PHP Code:

List<Shapeshapes = List;
shapes.addCirclexyradius ) )
shapes.addsquarex1y1x2y2x3y3x4y4) )
shapes.addtrianglex1y1x2y2x3y3 ) ) 

To demonstrate an understanding of inheritance in this exercise, have both the triangle and square object extend a polygon object.
You can use this formula for the area:
http://i.imgur.com/Zc1g5lu.png

Some links to get you started result from some simple google searches:
http://www.tutorialspoint.com/cplusp...nheritance.htm
http://stackoverflow.com/questions/2...l-methods-in-c

If this exercise seems a bit daunting, other nice features to look at include generics(templates) and operator overloads.

http://www.smashcompany.com/technolo...which-must-end
http://pivotallabs.com/all-evidence-...eing-bull****/

OOP is garbage.

Quote:

Posted by Emera (Post 543053)
Is it actually possible for members in this community to have a discussion without it turning into an elitist bull****-flinging contest, or...?

Is it possible for multiple humans with differing opinions to have a discussion without the same? Not typically. Politics, religion, etc...

jwd 04-18-2015 01:05 PM

Functional programming is a good paradigm to get your head round. Even if you're using a language that isn't typically functional, the lessons and habits learned will improve your code.

Unfortunately, GScript doesn't make this easy past a basic point, with a lack of lexically scoped variables and closures. It will still improve your code, regardless.

No excuse, however, with C++, with the new standard.

Zachary 04-18-2015 01:19 PM

Quote:

Posted by jwd (Post 554919)
Functional programming is a good paradigm to get your head round. Even if you're using a language that isn't typically functional, the lessons and habits learned will improve your code.

Unfortunately, GScript doesn't make this easy past a basic point, with a lack of lexically scoped variables and closures. It will still improve your code, regardless.

No excuse, however, with C++, with the new standard.

Agreed.

hosler 04-18-2015 06:41 PM

You can argue that ASM is just human readable machine code.

jwd 04-18-2015 08:03 PM

I can't remember which arch (I think MIPS) or the specific instructions, but there was something about inconsistent arrangement for a couple of opcodes where the corresponding instructions in assembly looked consistent. I think glossing over that is some level above writing pure opcodes.

From what I recall, a lot of assemblers give you convenience macros/pseudo-instructions, which assemble into several machine instructions.

I think, however, it's such a small level above machine code that making a big fuss over the distinction is perhaps pedantic.

hosler 04-18-2015 09:15 PM

So ASM actually gets run through a little interpreter?

jwd 04-18-2015 10:09 PM

There is some level of text processing to assemble into object files. I imagine it wasn't a stretch to include built-in and user-defined macros on top of that. It's still architecture dependent because it is so close to machine code as you say but I think there is a bit of wiggle room for convenience features. If you notice, assemblers have varying syntax from assembler to assembler. Code written for gas is different from nasm, etc. With some assemblers, the difference is minimal but enough to catch you out, such as literals, referencing memory, etc.

I think with GNU in particular it uses at&t syntax by default (though accepts Intel too). With that, the order of operands are reversed so typically, with Intel as common, you have:

PHP Code:

add 2eax 

Where, with at&t, you have:

PHP Code:

add eax, $

They do the same thing. Both add 2 to whatever's in the eax reg.

Jatz 04-19-2015 04:14 AM

Quote:

Posted by Zachary (Post 554896)
Wrong. Assembly is lower-leveled than C++ and higher-leveled than machine language. C++ is actually compiled into assembly.

When I said of the languages, I was referring to the languages already mentioned.

Spirit19 04-19-2015 03:25 PM

Can someone recommend me a compiler for C++? Learning code isn't easy if I can't run it :I

EDIT: Now that I think about it. What should I write the actual code in? xD

hosler 04-19-2015 03:38 PM

i use gcc, but i think visual studio comes packaged with one.

Spirit19 04-19-2015 03:58 PM

Can I code C++ in Visual Studio?? I thought it was only for Visual Basic.

hosler 04-19-2015 04:06 PM

Visual studio supports a handful of languages


All times are GMT. The time now is 03:51 PM.

Powered by vBulletin/Copyright ©2000 - 2026, vBulletin Solutions Inc.