Wednesday, 29 November 2017

Reserved keyword in modern c++

In our previous post we talk about variables and their naming conventionintroduction to variables in modern c++ we explain we should never use the c++ reserve keywords as our variable names... we hereby provide all the list of reserved keywords in modern c++ these are name that is defined by the c++ language itself so you should not use them as your variable names

char
char16_t
char32_t
class
false
float
short
wchar_t
auto
bool
decltype
double
int
long

break
do
for
case
catch
goto
if
switch

alignas
alignof
and
and_eq
asm
atomic_cancel
atomic_commit
atomic_noexcept

bitand
bitor



compl
concept
const
constexpr
const_cast
continue

default
delete

dynamic_cast
else
enum
explicit
export
extern

friend

import
inline

module
mutable
namespace
new
noexcept
not
not_eq
nullptr
operator
or
or_eq
private
protected
public
register
reinterpret_cast
requires
return

signed
sizeof
static
static_assert
static_cast
struct

synchronized
template
this
thread_local
throw
true
try
typedef
typeid
typename
union
unsigned
using
virtual
void
volatile

while
xor
xor_eq
override
final
transaction_safe
transaction_safe_dynamic
if
elif
else
endif
defined
ifdef
ifndef
define
undef
include
line
error
pragma


Never miss out any of this blog articles, Receive our regular updates by joining our mailing list, connect with us on facebook, follow us on Google+ connect with us on Pinterest, add us on Tumblr, and follow us on Twitter.

Never forget to promote and recommend this post to others, Remember sharing is caring.
For other suggestions and queries that are not related to this post should be forwarded to us through the contact form or better still you can get in touch with us on WhatsApp with this number +2348163702703.

Enjoy and have fun!

©2017, copyright Ogunleye Peter Opeoluwa
Admin @Idea4novice : Tech Weblog On How Tos, Tips And Tricks

Labels: , ,

Introduction to variables in modern c++

Ok now we have set up our compiler, we have even created an  hello-world program really life is becoming awesome. But that is not where we want to stop we want to create real life program, yes that is what this blog is all about and we ourselves can not wait to get you there, so we will continue by learning about variable yes variable.

What is a variable?

Remember elementary mathematics where they will give you an equation like this "x+1=2" find x
well this mathematical question make us know that x is used to represent something, or maybe say a place holder for a value which in the case of that equation is 1, so in the equation "x+1=2" x is used as a place holder for the value one. x is the variable in the equation it is simply a placeholder or storage location for your data or say value.

So Variable in C++?

Variable in c++ are used to store values so you can use them later in your code

Features of a C++ Variable

A c++ variable has a name also called an identifier, a type which specify the type of data or value that can be stored in the variable, maybe a number, characters, etc trust we will talk further on this, and sometimes a scope specifier which specify where you variable is visible or alive.

Example of a c++ Variable

int x;

"x" is the variable name "int " is the data type you intend to store in x.

Creating variables in c++ 

To create a c++ variable you need to write a c++ statement which is a line of c++ expression

In the statement you will specify the type and the identifier which you will use to refer to you variable... This is know as variable declaration.
Note. all c++ statement must ends with a semicolon ";" which tells the compiler that you have finish a statement and to take the next codes as another statement. and also white spaces are ignored

Variable initialization

In the above code
int x;
we created a variable or let us say in a more scientific way we declared a variable but this variable has nothing inside it it is just an empty variable that can store an integer(counting numbers)
how do we store a value in our variable? it very simple!

since you have declared your variable you can easily assigned value to it just by using the variable name

x=5;

the above statement just assign the value 5 to variable x so where you use the variable x in your code the compiler understand it as 5 unless you assign another value to it.

you can also assign value to your variable during declaration it is the same thing!!!

int x=5;


Variable naming rules

The name you use for your variable can be anything and can of any length, but i know you want to keep it short and descriptive. like  int myFirstNumber;

But it must not be any of the c++ reserved keywords i.e the words that are defined in c++ language itself like " int, char" etc

You should not let you variable contain symbols such as =+-()*&^%$#@! or else  you may get an error, be careful my friend.

Your variable can begin or contain or end with an underscore _ e.g  int _x;

An example Program

#include<iostream>

int main(){
int x;
x=1;
std::cout<<x<<std::endl;

x=x+1;
std::cout<<x;

}

that is a an simple program that creates a variable x assign the value 1 to it output it, and add 1 to the value stored in it and the output the resulting value!!! we are getting there little by little!!!

note the std::endl means end line which make the console break the line before continuing on the output just like the way we use the enter key!!!

Next tutorial we will be talking about data type because numbers are not the only thing in c++ there is more!!!!!!!!!!!!!!!!!!!!! just stay tuned....


Never miss out any of this blog articles, Receive our regular updates by joining our mailing list, connect with us on facebook, follow us on Google+ connect with us on Pinterest, add us on Tumblr, and follow us on Twitter.

Never forget to promote and recommend this post to others, Remember sharing is caring.
For other suggestions and queries that are not related to this post should be forwarded to us through the contact form or better still you can get in touch with us on WhatsApp with this number +2348163702703.

Enjoy and have fun!

©2017, copyright Ogunleye Peter Opeoluwa
Admin @Idea4novice : Tech Weblog On How Tos, Tips And Tricks

Labels: , ,

C++ Hello World : C++ beginner tutorial

After setting up your compiler as explained in the previous article How to setup a compiler for modern c++ this post will guide you through creating an hello world program in c++, of course we will go past that you just need to stay tuned!

C++ hello world example

create a new c++ project in your ide then paste the following code.

#include<iostream>

int main(){
std::cout<<"hello world";

}

compile and run and see the magic... but wait it is not all magic, it all follows a principle they call syntax.. ok so we are going to explain

the first line #include<iostream>
is what they call the prepocessor which is just like a message to the compiler, in this case we are telling the comiler to include a library which is used for stream input and output and well a stream is just a flow of byte or say characters. so the iostream library is what you need when you what to input or output characters it contains cout for output and cin for input.
the int main(){} is the program entry point the place where your code begin execution.
std is a namespace just think of namespace like a wrapper of functions for now, so std is a wrapper that contain all c++ standard libraries include cin and cout, believe me there are tons of non standard library for c++ you can use in you code but for now run this code and make sure you understand every line if there are questions or error feel free to ask in the comment section.



Never miss out any of this blog articles, Receive our regular updates by joining our mailing list, connect with us on facebook, follow us on Google+ connect with us on Pinterest, add us on Tumblr, and follow us on Twitter.

Never forget to promote and recommend this post to others, Remember sharing is caring.
For other suggestions and queries that are not related to this post should be forwarded to us through the contact form or better still you can get in touch with us on WhatsApp with this number +2348163702703 or 08119482654.

Enjoy and have fun!

©2017, copyright Ogunleye Peter Opeoluwa
Admin @Idea4novice : Tech Weblog On How Tos, Tips And Tricks

Labels: , ,

Tuesday, 28 November 2017

How to setup a compiler for modern c++

In continuation to our recent article Introduction to modern c++ we will continue by posting how to set up a working environment for you to be able to create software using modern c++

To start with you will need an IDE which is the short for integrated development environment,
this is a software that enables you to write code using the provided text editor and compile it using a compiler that has been integrated in  it.

IDE that support modern c++ for windows


  1. Microsoft visual studio 2013 and above
  2. latest version of codeblocks, etc
you can check google for the link to download any of the two
there are lot of IDE that you can use, but as a beginner i advice you stick with one of the listed two above though visual studio is preferable.


Never miss out any of this blog articles, Receive our regular updates by joining our mailing list, connect with us on facebook, follow us on Google+ connect with us on Pinterest, add us on Tumblr, and follow us on Twitter.

Never forget to promote and recommend this post to others, Remember sharing is caring.
For other suggestions and queries that are not related to this post should be forwarded to us through the contact form or better still you can get in touch with us on WhatsApp with this number +2348163702703 or 08119482654.

Enjoy and have fun!

©2017, copyright Ogunleye Peter Opeoluwa
Admin @Idea4novice : Tech Weblog On How Tos, Tips And Tricks

Labels: ,

Introduction to modern C++

It is now often to see on the internet recently talks about modern c++. Many people wonder on what modern c++ is, is it a new language on it own? Is a new language created from c++ just like c was created from c. No my friend it is not a new language, think of it as an update to c++, so as to fit in with modern programming languages like JavaScript, Go, Rust, Dart, Java 8 etc.

Which c++ is old and which one is modern?
The old version of c++ are, c++98 and c++03
While the new ones are c++11, c++14,c++17 and the proposed c++2a (2020)

What is in modern c++

C++11

  • Automatic type declaration using the auto keyword
  • New type declaration using decltype
  • The range for loop
  • list initialization
  • Static assert
  • Type alias
  • override and final specifial
  • lambda expression
  • move construction
  • noexcept keyword
  • parameter packs
  • and some new container libraries
C++14
  • variadic template
  • substitution failure is not an error
  • integer sequense
C++17
  • Dynamic exception specification
  • std::optional
  • std::any
  • variant
  • concept
  • execution policy
  • filesystem library
  • Ranges etc.
It is our plan to post on these topics one by one in the future so stay tuned


Never miss out any of this blog articles, Receive our regular updates by joining our mailing list, connect with us on facebook, follow us on Google+ connect with us on Pinterest, add us on Tumblr, and follow us on Twitter.

Never forget to promote and recommend this post to others, Remember sharing is caring.
For other suggestions and queries that are not related to this post should be forwarded to us through the contact form or better still you can get in touch with us on WhatsApp with this number +2348163702703.

Enjoy and have fun!

©2017, copyright Ogunleye Peter Opeoluwa
Admin @Idea4novice : Tech Weblog On How Tos, Tips And Tricks

Labels: ,