Jump to content

Python List Type Container In C++?

LtStaffel

Hello,

In Python you can do something like:

 

myList = ["firstItem", "secondItem"]
myList.append("thirdItem")
print (myList)

 

and it would return something like:

 

["firstItem", "secondItem", "thirdItem"]

 

Now my point in saying that is because I am trying to do the same type of thing in C++, but can't find a way to. I'd basically like to define an empty list, (or array is the closest thing I could find upon Googling), and then be able to later add to it any amount of items I like.

People say it is impossible to add items to an array during runtime, and to use vectors, but I'm not sure they would even necessarily do what I can in Python.

 

What do you all suggest I do?

 

I'd write this in Python but C++ compiles to .exes much more easily, (I don't want to set up py2win32exe or whatever), and I feel that this type of skill is a good one to have if I'm going to write C++.

 

Thanks in advance!

Join the Appleitionist cause! See spoiler below for answers to common questions that shouldn't be common!

Spoiler

Q: Do I have a virus?!
A: If you didn't click a sketchy email, haven't left your computer physically open to attack, haven't downloaded anything sketchy/free, know that your software hasn't been exploited in a new hack, then the answer is: probably not.

 

Q: What email/VPN should I use?
A: Proton mail and VPN are the best for email and VPNs respectively. (They're free in a good way)

 

Q: How can I stay anonymous on the (deep/dark) webzz???....

A: By learning how to de-anonymize everyone else; if you can do that, then you know what to do for yourself.

 

Q: What Linux distro is best for x y z?

A: Lubuntu for things with little processing power, Ubuntu for normal PCs, and if you need to do anything else then it's best if you do the research yourself.

 

Q: Why is my Linux giving me x y z error?

A: Have you not googled it? Are you sure StackOverflow doesn't have an answer? Does the error tell you what's wrong? If the answer is no to all of those, message me.

 

Link to comment
Share on other sites

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

×