First note: You are using double. In a real program, you would never use floating-point numbers to represent exact money amount, but that's a bit beyond the scope of what's necessary here. But second, you use greater<float>() in your sort method. You should use greater<double> here, to match your data type.
Second note: If your exe were actually crashing, it would most likely generate an Event log in your event viewer. After running your exe and letting it "crash", if you open your Event log and navigate to Windows Logs --> Application (wait for it to load), do you see any error messages that relate to your exe?
Another minor note for the future: please don't edit you OP more. It makes the thread less linear; just add additional information in new posts.
I suggest looking up a tutorial on Visual studio debugging or breakpoints. It's hard to
visually show you what exactly to do, beyond what I already mentioned: Start your exe. Then in Visual Studio, go to Debug --> Attach to Process --> then find your exe in the list, and click Attach. Then place a break point after your cin >> statements, and step through your code with F11 (or Debug --> Step Into) once you're debugging.
I ran your code (creating my own Stock class)
1 2 3 4 5 6 7 8 9 10
|
class Stock {
public:
string ticker;
double currentPrice;
double targetPrice;
double lossPrice;
double successChance;
double lossChance;
double expectancy;
};
|
I don't see any flagrant errors other than the minor precision issue with float vs. double.
I think your problem is the well-known beginner issue:
https://cplusplus.com/forum/beginner/1988/
You are double-clicking on the exe, which produces a temporary window, and once the program is over, this window disappears. This has been discussed ad nauseum in the linked thread above, but what I suggest is running the program through an existing cmd prompt instead of double-clicking it from your File explorer.
From your File explorer, go to the folder that contains your exe.
Then, click into the whitespace of the address bar, and type "cmd" and hit enter.
Then, in the command window, type the name of your exe and hit enter to run it.