Jump to content

So I was just starting with writing codes in visual studio and it turns out that I couldn't. I know c++ and c and have done some basic programming in both of these languages.(By basic I mean like checking a palindrome, linked lists and queues and all that but I really don't know about the new standards and now that I am writing in visual studio nothing seems to work.

For example (I will be talking about c++ from now on)

 

I used to write code without that

 

using namespace std 

which I see on many sites nowadays. I didn't write code for like 2 years after learning the basics of the language.

 

Also, the cout statement to print the output doesn't work and gives an error.

 

I researched about it and I think I have learnt the older version of the language and these are new things in it. 

So if there anyone who can help me out with this and tell me where can I start learning things and clear the above doubts. Thanks in advance :)

Link to comment
https://linustechtips.com/topic/877320-c-code-writing-in-visual-studio/
Share on other sites

Link to post
Share on other sites

NEW PC build: Blank Heaven   minimalist white and black PC     Old S340 build log "White Heaven"        The "LIGHTCANON" flashlight build log        Project AntiRoll (prototype)        Custom speaker project

Spoiler

Ryzen 3950X | AMD Vega Frontier Edition | ASUS X570 Pro WS | Corsair Vengeance LPX 64GB | NZXT H500 | Seasonic Prime Fanless TX-700 | Custom loop | Coolermaster SK630 White | Logitech MX Master 2S | Samsung 980 Pro 1TB + 970 Pro 512GB | Samsung 58" 4k TV | Scarlett 2i4 | 2x AT2020

 

Link to post
Share on other sites

38 minutes ago, Enderman said:

Appreciate your answer. But I don't know how to start programming with these new standards. Where can I find these?

After a bit of research, I could find some seminars about the new releases but couldn't find a starting point as I couldn't understand what was he saying despite knowing the programming language.

Link to post
Share on other sites

Post your code. Most likely you forgot to include something. Remember that breaking backwards compatibility in a programming language is considered to be a big no no. So whatever you learned 30+ years back will work today(exaggerating to make my point).

Link to post
Share on other sites

What is your reasoning for using VS, since if it's just to have a good IDE on windows then I'd suggest giving clion a try. Aside from costing a fair bit if you can't get it for free through some mean (opensource/education/etc) it's a really nice IDE and uses CMake so if you're code works in it and you didn't use any OS specific libraries it should work on other OSes too.

Link to post
Share on other sites

On 12/25/2017 at 6:40 PM, Abhishek sharma said:

So I was just starting with writing codes in visual studio and it turns out that I couldn't. I know c++ and c and have done some basic programming in both of these languages.(By basic I mean like checking a palindrome, linked lists and queues and all that but I really don't know about the new standards and now that I am writing in visual studio nothing seems to work.

For example (I will be talking about c++ from now on)

 

I used to write code without that

 

using namespace std 

which I see on many sites nowadays. I didn't write code for like 2 years after learning the basics of the language.

 

Also, the cout statement to print the output doesn't work and gives an error.

 

I researched about it and I think I have learnt the older version of the language and these are new things in it. 

So if there anyone who can help me out with this and tell me where can I start learning things and clear the above doubts. Thanks in advance :)

Either you include the namespace (not recommended) with:

using namespace std;

or you explicitly write out the full namespace:

std::cout << "Hello, World!" << std::endl;

Afaik, that's how the standard has always been. It's possible that some ancient compilers (Borland, perhaps ?) did not strictly follow the standard and imported the std namespace by default. Most stuff like this is caused not by changing language standards but by old compilers being too lenient.

Link to post
Share on other sites

a lot of tutorials include the std namespace for a bit cleaner syntax, but it's not good practice in general. Reason being, it's a namespace that you can't control. Even if you say "well i'll just avoid making my method names collide with STL libraries to prevent ambiguous calls", there's nothing stopping there being future additions to the STL that collide with your methods.

 

For example, you know that the STL has a vector class, so you call your custom container class NodeVector or something. Now you don't have a collision, and you can use namespace STD without collisions. But then 5 years from now, the need for a NodeVector class in the STL is so great that they add it to the library and it has the same function signature as yours, now in code you wrote 5 years ago you have an ambiguous function call that was fine when it was written.

Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×