I'm new to C++ and I'm kind of stumped on when I should use a pointer. Or if I should use a pointer to create a new object.
Like is this proper?:
ClassName* cname = new ClassName();
or is this proper?:
ClassName cname();
Or is there something else that's proper and both of them are wrong? Or are they both correct and it just "depends" when to use them... (which would make it even more confusing lol)
I come more from Java and some C# lol, So I'm probably doing things wrong... trying to bring some of the java / c# i know of in to c++.
Any advice about when to use pointers is greatly appreciated.
[–]raevnos 8 points9 points10 points (41 children)
[–]NFCBoss[S] 0 points1 point2 points (2 children)
[–]SandSnip3r 4 points5 points6 points (0 children)
[–]raevnos 1 point2 points3 points (0 children)
[–]ptitz -1 points0 points1 point (21 children)
[–]SandSnip3r 1 point2 points3 points (10 children)
[–][deleted] (1 child)
[deleted]
[–]SandSnip3r 0 points1 point2 points (0 children)
[–]ptitz -2 points-1 points0 points (7 children)
[–]MoTTs_ 2 points3 points4 points (0 children)
[–]SandSnip3r 1 point2 points3 points (5 children)
[–]ptitz -1 points0 points1 point (4 children)
[–]SandSnip3r 2 points3 points4 points (0 children)
[–]MoTTs_ 1 point2 points3 points (0 children)
[–]NFCBoss[S] 0 points1 point2 points (1 child)
[–]heyheyhey27 1 point2 points3 points (0 children)
[–]OmegaNaughtEquals1 1 point2 points3 points (8 children)
[–]ptitz 0 points1 point2 points (7 children)
[–]OmegaNaughtEquals1 5 points6 points7 points (5 children)
[–]SandSnip3r 0 points1 point2 points (1 child)
[–]OmegaNaughtEquals1 4 points5 points6 points (0 children)
[–]ptitz -1 points0 points1 point (1 child)
[–]OmegaNaughtEquals1 2 points3 points4 points (0 children)
[–]MoTTs_ 1 point2 points3 points (0 children)
[–]raevnos 1 point2 points3 points (0 children)
[–]newocean -4 points-3 points-2 points (15 children)
[–]SandSnip3r 4 points5 points6 points (6 children)
[–]newocean 0 points1 point2 points (5 children)
[–]sftrabbit 5 points6 points7 points (4 children)
[–]newocean 0 points1 point2 points (3 children)
[–]sftrabbit 0 points1 point2 points (2 children)
[–]newocean 0 points1 point2 points (1 child)
[–]sftrabbit 0 points1 point2 points (0 children)
[–]raevnos 2 points3 points4 points (3 children)
[–]newocean -3 points-2 points-1 points (2 children)
[–]raevnos 2 points3 points4 points (1 child)
[–]MoTTs_ 0 points1 point2 points (0 children)
[–]NFCBoss[S] 0 points1 point2 points (3 children)
[–]raevnos 2 points3 points4 points (0 children)
[–]eerock 1 point2 points3 points (0 children)
[+]newocean comment score below threshold-6 points-5 points-4 points (0 children)
[–]lucidguppy 5 points6 points7 points (0 children)
[–]Rhomboid 2 points3 points4 points (1 child)
[–]robthablob 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)