Jump to content

Recommended Posts

Posted

I am looking to hire someone to create a series of C++ tutorials similar to our Lua tutorials. They do not have to cover every C++ topic, just the ones we care about when programming Leadwerks with C++. These are the topics:

  • Introduction to C++
  • Code comments
  • "if" statements
  • Operators
  • Loops
  • Containers (lists, vectors, and maps)
  • Functions
  • Classes (inheritance, static functions / members)
  • Actors (new Leadwerks C++ Actor class, similar to Lua script)
  • Visual Studio debugger
  • Threads (Basic concepts, Mutexes, shared memory read/write access) This is mostly just a theoretical example for learning, I don't expect users to use multithreading much.

The documentation will be in an XML file like what we are using now:

https://www.leadwerks.com/documentation/Tutorials_Lua-Scripting_Introduction-to-Lua.xml

 

Any image files used will be in a subfolder like this:

img/name-of-the-lesson/imagefile.jpg

 

This is by no means meant to be exhaustive documentation of the C++ programming language (no one can do that), it is just meant to take people from zero knowledge to understanding how to use Leadwerks in C++.

 

The lessons can refer to ideas in Lua "this is like how we did X in Lua" but should be self-contained and assume no background knowledge on the part of the reader.

 

Please post here if you are interested.

Let's build cool stuff and have fun. :)

Posted

Im interested to do this.

I'm sure you'd do a great job of this, but since English isn't your first language it would require a lot of proof-reading on my part.

Let's build cool stuff and have fun. :)

Posted

snapback.pngaiaf, on 17 May 2017 - 08:35 PM, said:

 

Im interested to do this.

I'm sure you'd do a great job of this, but since English isn't your first language it would require a lot of proof-reading on my part.

 

Was interested but I guess there will be the same problem for me

Roland Strålberg
Website: https://rstralberg.com

Posted

Hey Roland didn't you do a youtube series on C++ in Leadwerks?

 

I can't find it. Did you remove it?

Yes I did. But then I switch to a new account, deleted the old one. Of course I forgot to backup them. Yes! Totally idiotic but that's what happened. About 20 videos about C++ lost sad.png Sorry about that

  • Upvote 1

Roland Strålberg
Website: https://rstralberg.com

Posted

Shame.

 

From memory you covered most of the topics Josh is after.

Yep. Started with "No knowledge of C++" then covered most things. Classes, Inheritance, Polymorfism, Standard Templates and so on ending up in some Leadwerks scene samples. To bad they are lost and I have no own backup either as I bough a new pc since then and AGAIN!!! was to lazy to make a DVD backup as I had it on YouTube...

Roland Strålberg
Website: https://rstralberg.com

Posted

I'm nearly through the lessons. It's actually pretty hard to separate out what the user needs to know and give it to them in a digestable format.

 

The containers tutorial really makes the problems of C++ iterators glaringly obvious. That's the only way to do fast removal of objects from a list and they are so incredibly error-prone.

Let's build cool stuff and have fun. :)

Posted

I'm nearly through the lessons. It's actually pretty hard to separate out what the user needs to know and give it to them in a digestable format.

 

The containers tutorial really makes the problems of C++ iterators glaringly obvious. That's the only way to do fast removal of objects from a list and they are so incredibly error-prone.

 

Hi there Josh.

 

First of all the interator sample has an error

 

std::vector myvector = {"Bob", "Jane", "Fred"};
for (auto it = myvector.begin(); it != myvector.end(); it++)
{
std::string element = (*it);
Print(element);
}

 

 

should be

 


std::vector<std::string> myvector = {"Bob", "Jane", "Fred"};
for (auto it = myvector.begin(); it != myvector.end(); it++)
{
std::string element = (*it);
Print(element);
}

 

 

secondly you can create the vector and iterate in a less mysterious way

if you don't care what myvector actually is.

 

auto myvector = { "Bob", "Jane", "Fred" };

for each( auto element in myvector )
{
 Print(element);
}

 

if you do care its

std::vector<std::string> myvector = { "Bob", "Jane", "Fred" };

for each( auto element in myvector )
{
 Print(element);
}

  • Upvote 1

Roland Strålberg
Website: https://rstralberg.com

Posted

When using ranged based for loop like, you usually want to make the variable a reference.

 


std::vector<std::string> myvector = { "Bob", "Jane", "Fred" };

for( auto&& element : myvector )
{
Print(element);
}
[/Code]

 

Otherwise it's going to copy your string. The double && basically ensures it's a reference not a copy.

Posted

std::for_each() is part of STL so part of the language. Range based for loops are the syntax as Rick said(but seriously, use auto&&, otherwise it's a copy every iteration). Both achieve the same thing but the STL version is a little more awkward to use but you can specify a begin and end if you wanted to.

 

EDIT: i forgot to mention that ranged base for loops are also part of the language as of c++11 iirc

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...