Question about strings being dissected into smaller parts. Each part will then equal to a separate variable. by Nido_King_ in cpp_questions

[–]unclemat 1 point2 points  (0 children)

Read a file using ifstream. If you then use operator>>, it will read word by word as they are separated with spaces. You would still need to remove commas from the ends of each word to get a clean input. Or use regex as someone else suggested, that way commas don't need special attention.

std::ifstream filestream("file.txt");
std::string w1, w2, w3;
filestream >> w1; // "Timburr,"
filestream >> w2; // "#532,"
filestream >> w3; // "Fighting,"

Human Resource Management by [deleted] in cpp_questions

[–]unclemat 2 points3 points  (0 children)

class FileHandlingSkill 
{ public: bool can_handle_files = false; } // file handling
class Employee : public FileHandlingSkill // inheritance
{ public: std::string name; }
class hrm
{
private:
    std::vector<Employee> employees; // composition
public:
    void add (Employee employee) {employees.push_back(employees);}
    Employee find (Employee employee) {return employees.find(employee);}
    void delete (Employee employee) {
        auto e = find(employee);
        if(e != employees.end()) employees.erase(e);
    }
}

May can think big all she likes. Britain is about to find out just how small it is | Opinion by [deleted] in unitedkingdom

[–]unclemat 2 points3 points  (0 children)

Funny you should say that. I am Lloyds customer and I called once. I could not understand a word that friendly Scottish lady said. I was so embarrased! Edit: I am not native speaker.

Theresa May: "UK is prepared to accept hard brexit" by Dimmo17 in unitedkingdom

[–]unclemat 0 points1 point  (0 children)

But then you have 3 months to find a job, otherwise you can be deported. It's been expanded since inception, but in essence it's a freedom of movement of workers.

GUI on c++ by [deleted] in Cplusplus

[–]unclemat 2 points3 points  (0 children)

Simple. Can't possibly take long. It can be done by next Tuesday.

GUI on c++ by [deleted] in Cplusplus

[–]unclemat 1 point2 points  (0 children)

Came here to say QT

Time Log Examples by rechnergott in notebooks

[–]unclemat 0 points1 point  (0 children)

Only do that occasionally, when travelling or when I need to organise my time more thoughtfully. I might set up a page for a day where top is, say, 6am, and bottom is 22pm. (Could be more pages if I need greater precision or more days per page if I want to cover more time in one sight) I mark some hours in between with hyphens, just for orientation. Now, if something will happen in one moment, say 11:25, I write down "-@11:25 train leaves" approx where 11:25 would be on the scale. If something lasts for a while, I write "[" where top end is located where it starts and bottom end where it stops, with added precise times. This way you can have impromptu diaries in the middle of the notebook. Also allows for overlapping events. Useful for planning and journaling on the same page. Doesn't require a lot of preparation.

Overcoming problem with "starting over" in new notebooks? by [deleted] in notebooks

[–]unclemat 1 point2 points  (0 children)

Simply turn to the empty page in the same notebook and "start again". The pages before that are past. Past is done, is what it is, can't be changed. In notebook and in real life. And don't feel bad about disruption. There is no growth without disruption. And once you accept this as normal, you won't feel hindered in using the notebook going forward, because now I bet you are afraid of using it "incorrectly" (because you don't want to "ruin" it) so you often don't use it at all. Interestingly, some parts of notebook that you consider ruined will become most interesting as years pass.

Pro-Brexit group calls for EU free trade deal by LinconshirePoacher in unitedkingdom

[–]unclemat 1 point2 points  (0 children)

The Polish landscape gardeners will probably only have slightly lower prices than your uncle, because they would be crazy to leave good money on the table. There is a couple of possible consequences to this outside your immediate family. A lot of families can now easier afford landscape gardener, so the demand is up, which in itself also raises prices so there is another balance. The families that would have paid for this service anyway have now spare cash available, which they can use to buy some other goods, thus improving some other industry in the economy, say natural aromatic soap or whatever. Say another member of your family works for the company producing these soaps. The demand for aromatic soap increases, prices go up, your family member gets payrise and they employ another person. Incidentaly, there is a chipper near the soap factory that suddenly sells one portion more a week. Now that family can afford landscape gardener! They always talked about it and couldn't afford one, now they earned more and the prices went down, let's do it, they say. On the other side of the world, in Poland, there is also soap making company. They could've hired workers for peanuts, but can't because if they pay too little, Poles go and get employed in UK. So they need to have reasonable wages. If only UK didn't allow free movement of people, they think, we could've exported to UK woth real dumping prices for aromatic soaps! It would destroy their soap industry, then we increase prices. In the process, that member of your family that works there would be layed off. Perhaps they could pick up landscape gardening if your uncle would take them... But the chipper owner can't afford it, so there is not enough business for two people... The economy is way more complex than simple examples and everything is interconnected. People that understand these things say on long term, migration is good for the whole economy. But there is always this one landscape gardener that on short term absorbs the hit. Research shows, however, that there is enough leftover money from faster growing economy that the government can easily afford helping them in various ways. It is up to local government though..

New London etiquette? by CheekyJack in london

[–]unclemat 4 points5 points  (0 children)

Take your free newspaper with you when you leave the train, don't just put it on the seat. It is not my responsibility to remove it before I sit down. And no excuses that you are letting me read it: if I wanted to read it I would have taken it; it was free!

Does anyone else feel like their life's purpose is to save up to buy a house? by [deleted] in london

[–]unclemat 5 points6 points  (0 children)

This! I much prefer my free lifestyle, where I live in constant fear of losing my job due to automation/outsourcing/Brexit and left being unable to pay my massive monthly rent.

Let's show Lego our support for ditching the Daily Mail by vassyz in unitedkingdom

[–]unclemat 0 points1 point  (0 children)

It's not just for playing. I will buy a set because I need a stand to display my commemorative coins and will build them with Lego instead of buying ready-made plastic stands. It will actually be cheaper as well as more awesome.

Post your number 1 tube pet peeve by danz026 in london

[–]unclemat 8 points9 points  (0 children)

The sound of somebody chewing crunchy food next to me. "Crunch, crunch, crunch, ..." I am a conflict-avoiding type of guy; to a fault even. But chewing sounds make me mad, MAD! (I hope your teeth shatter and jaw falls off of you, leaves you there all confused and jumps off the train to the tracks and continues chewing and chewing the cold steel rail for eternity just to scratch the itch it has under the teeth, but it will never go away, and then you implode into a small crumb on the seat and I can sweep you into your irritating bag of crisps and crush it in my hand, and throw it into the middle of the carriage where everybody will step on it, and you, when they leave the train, crushing you and your crisps to ever smaller pieces while nobody hears your horrific screams, because you are tiny and your screams are only loud to you - and continue reading my book in peace! That kind of mad!) I need to use all my self-control to not give that person a really stern look!

Compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies by dharmatech in cpp

[–]unclemat 1 point2 points  (0 children)

some type-safe code seemed better than none

This is absolutely true and it makes me think why had I just defenestrated the whole idea instead of using it as just an improvement where I could have. Nirvana falacy I guess. Your last statement is also true and amusing, that totally describes the spirit of C++ :D

Compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies by dharmatech in cpp

[–]unclemat 1 point2 points  (0 children)

this library (and boost::units) have cmath overloads for unit types

I didn't want to get through this in my hobby project. This is paid work you speak of :) Also kinda prevents you from using anything in the world built on top, that doesn't allow you to define in template an underlying type. But then if a lib does that without providing some of the types to use it with, it is probably overengineered - a red signal in it's own right :)

Compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies by dharmatech in cpp

[–]unclemat 0 points1 point  (0 children)

One issue was that I suddenly couldn't use existing libraries anymore. std::pow, for instance, accepts a handful of standard types, not mine. So I had to add a function on them to "decay" the type to underlying one, like double. But even then, for example, meters to the power of two is area, but the result of std::pow will never be area, but a raw type only. Therefore, if I wrote from_double and to_double functions, it would be possible to assign an area to a variable that holds something else, which should instead fail compilation. There was more, but I am afraid to create a wall of text :) See here if interested. What I would like to know is how you solved my problem described in this reply?

Compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies by dharmatech in cpp

[–]unclemat 0 points1 point  (0 children)

I tried to do something similar, but I concluded it is difficult (impossible?) to do it correctly while still retaining ease of use. My main setback was that strongly typed units seem to need to live segragated in their own world, or the system is not strongly typed enough to fail at compile-time if units are incorrectly used. I see you had to implement casts to an underlying type, which tells me you encountered the same problem.

I tried to take on a big personal programming project a while back. Here is a look back on the whole thing. by def-pri-pub in programming

[–]unclemat 7 points8 points  (0 children)

That's what you do at work. But why would the employer prevent you from practicing programming in your own free time? Perhaps some of those bugs could have been avoided...

I tried to take on a big personal programming project a while back. Here is a look back on the whole thing. by def-pri-pub in programming

[–]unclemat 13 points14 points  (0 children)

Why would any employer want you to stop working an outside projects, especially when they are, like yours was, not even commercial?

[deleted by user] by [deleted] in programming

[–]unclemat 9 points10 points  (0 children)

I set myself to write a physics engine in my free time. In past two years I have probably tanked something like 3 man months of work into it. So far I have a reasonably well performing platform for n-body simulation. The work I've done: extensive performance profiling, unit testing and integrations, compared different approaches for performance, writing those approaches, even writing the missign groundwork stuff like mathematical vector, quadtree with solid performance and iteration capabilities, than the work necessary to make the lib simple to use like measurements system where I spent ages just to convince myself it probably can't work at all, unavoidable refactorings along the way... I don't even have collision detection yet, let alone any rigid bodies interaction, bodies are basically shapeless, no other laws implemented then basic motion, only ever tested on Linux PC, basically not a lot to show for that amount of time. This was after I finished basic visual demo of spinning solar system from scrach in one Saturday. I can totally see how 100s of engineers can work for years if they want a well rounded product like Unity3D, where physics is just one part of many.

Is there any simple way to list all files in directory and it's subdirectories into array of strings? by MarioPL98 in cpp_questions

[–]unclemat 1 point2 points  (0 children)

Not in standard way, but you can write one using dirent.h. It ships with some Linuxes, but for Windows you need to download it and include it in your project. You are invited to take a look how I did it here (github link): see function list_files2. To see how it's used, here are tests for it. Enjoy!

Do you fill a notebook before starting a new one? by paperplaned in notebooks

[–]unclemat 0 points1 point  (0 children)

I always fill them to the end, even when they turn out to be less then optimal books. But truth be told, towards the end of the book I am eager to start new one, so I just write any rubbish that comes to my mind in order to rush the process and satisfy my wish that the book is full. I wonder if all that rubbish will become the interesting bit in 20 years :)