• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Well that solves that!

Thanks.

Any specific reason to use const there? Style?

If there's no reason a function should need to modify something, use const. That's literally what it means. Adding two things should not require modifying one of the original things. It should return a new thing. If it were an operator += though, then you wouldn't be able to use const.
 

JesseZao

Member
hey, so I coded up the card game Dominion in Python. it's playable by up to 4 people in a console window right now, but i wanted to make it available online so only my friends and i could play using it. what would i need to learn to make this playable through a web browser for me and my friends? ive heard of Django and Flask, is that what i should look into?

You just made me remember isotropic :( sad day.
 

Mepsi

Member
I was wondering if anyone here could point me in the right direction for what I'm after. For the last 5 years I've been working as a developer at 2 different companies using a variety of programming languages such as XBase++, C#, Java and a little bit of C++. The thing is I am completely self taught, and found it very difficult to find a job here in the UK without a degree.

The 2nd job I was in I was there for 3 years, and was pretty much made to feel very inadequate in my skill set, even though I was one of the more experienced developers on the team I was payed less than half of any university graduate starting at the company, people would look down on me for not having a degree, it's odd, but it's what happened.

As you can imagine, over the space of 3 years it was a very soul destroying experience, I lost all confidence in any programming abilities I once had entirely. The thing is this is something that I have been doing as a hobby since I was 12 years old, something I have a very strong passion for and it would be a shame to completely throw it all away.

I finally left that job last week after having a long time off due to depression it caused me and now I'm basically looking for a way for me to start from scratch. I don't really know where to begin, but I'm after some sort of resources online presented in a course like structure with assignments and such so I can build my skills back up over time and maybe move back into working in the industry. Sorry about the long whiny post but I need to get it off my chest and genuinely need some advice on how I can go forward.
 

Bentles

Member
Any old hands know of a programming language that would serialize a 2D-array to

Code:
data|data|data|data|data}data|data|data|data|data}data|data|data|data|data}data|data|data|data|data}

So the rows end with '}' and the each element in a row is separated by '|'

sometimes it also uses tilde like this as some kind of separator:
Code:
~data~data~data~data~data

so this is possible:
Code:
data|data~data|data|data|data}data|data|data|data|data~data}

Anyone know anything that looks like this?
It's a data format for a system that came out in 1990 so that limits the language to some extent. Apparently this was a convenient way to represent data because the language had support for reading and writing these structures built into it. It's a tough thing to google :'(
 
I was wondering if anyone here could point me in the right direction for what I'm after. For the last 5 years I've been working as a developer at 2 different companies using a variety of programming languages such as XBase++, C#, Java and a little bit of C++. The thing is I am completely self taught, and found it very difficult to find a job here in the UK without a degree.

The 2nd job I was in I was there for 3 years, and was pretty much made to feel very inadequate in my skill set, even though I was one of the more experienced developers on the team I was payed less than half of any university graduate starting at the company, people would look down on me for not having a degree, it's odd, but it's what happened.

As you can imagine, over the space of 3 years it was a very soul destroying experience, I lost all confidence in any programming abilities I once had entirely. The thing is this is something that I have been doing as a hobby since I was 12 years old, something I have a very strong passion for and it would be a shame to completely throw it all away.

I finally left that job last week after having a long time off due to depression it caused me and now I'm basically looking for a way for me to start from scratch. I don't really know where to begin, but I'm after some sort of resources online presented in a course like structure with assignments and such so I can build my skills back up over time and maybe move back into working in the industry. Sorry about the long whiny post but I need to get it off my chest and genuinely need some advice on how I can go forward.

I'm self taught but ended up getting many highly coveted jobs and now my experience speaks for itself.

With 3 years experience you can probably find something else without much trouble. In the meantime maybe crack open some books and try to fill in the gaps on what you missed (most likely discrete math and algorithms)
 

Hypron

Member
Hey guys,

I was just wondering, what are the things that could potentially slow down compilation?

I can compile the APM Copter firmware in about 7-8 minutes on my home computer whereas it takes >40 minutes on my computer at university. Subsequent compilations take ~20s vs 2 minutes.

Both computers have fairly similar specs (i7-6700k, 16GB DDR4, OS stored on SSD, code stored on a mechanical HDD vs i7-4790, 16GB DDR3, mechanical HDD) and I'm using the exact same toolchain.

I thought it could be the AV software running on the uni PC so I deactivated it but it didn't make any difference, and I'm scratching my head as to what results in such a huge difference in compilation time...
 
Hey guys,

I was just wondering, what are the things that could potentially slow down compilation?

I can compile the APM Copter firmware in about 7-8 minutes on my home computer whereas it takes >40 minutes on my computer at university. Subsequent compilations take ~20s vs 2 minutes.

Both computers have fairly similar specs (i7-6700k, 16GB DDR4, OS stored on SSD, code stored on a mechanical HDD vs i7-4790, 16GB DDR3, mechanical HDD) and I'm using the exact same toolchain.

I thought it could be the AV software running on the uni PC so I deactivated it but it didn't make any difference, and I'm scratching my head as to what results in such a huge difference in compilation time...

Clock speed and disk speed are the 2 biggest factors. At home you've got an extra 400MHz per core (with 8 hardware threads), as well as SSD vs HDD. That could easily account for a 2-3x difference.

Edit: Same operating system on both computers?
 

upandaway

Member
I was wondering if anyone here could point me in the right direction for what I'm after. For the last 5 years I've been working as a developer at 2 different companies using a variety of programming languages such as XBase++, C#, Java and a little bit of C++. The thing is I am completely self taught, and found it very difficult to find a job here in the UK without a degree.

The 2nd job I was in I was there for 3 years, and was pretty much made to feel very inadequate in my skill set, even though I was one of the more experienced developers on the team I was payed less than half of any university graduate starting at the company, people would look down on me for not having a degree, it's odd, but it's what happened.

As you can imagine, over the space of 3 years it was a very soul destroying experience, I lost all confidence in any programming abilities I once had entirely. The thing is this is something that I have been doing as a hobby since I was 12 years old, something I have a very strong passion for and it would be a shame to completely throw it all away.

I finally left that job last week after having a long time off due to depression it caused me and now I'm basically looking for a way for me to start from scratch. I don't really know where to begin, but I'm after some sort of resources online presented in a course like structure with assignments and such so I can build my skills back up over time and maybe move back into working in the industry. Sorry about the long whiny post but I need to get it off my chest and genuinely need some advice on how I can go forward.
I don't think you'll gain much from trying to learn that stuff but it might help you calm down if you see what you've been "missing". If you want I can point out some of my classes' books. honestly when you have that much experience the degree shouldn't matter for dev jobs, that's what I've been told

Maybe learn some new technology like node js to get ahead? I know people who started working without a degree by focusing on learning the things that school never brings up
 

Hypron

Member
Clock speed and disk speed are the 2 biggest factors. At home you've got an extra 400MHz per core (with 8 hardware threads), as well as SSD vs HDD. That could easily account for a 2-3x difference.

Thanks, that's good to know. Would the SSD make a big difference if the code is stored on a HDD though? Edit: I can actually try that myself haha.

Edit: Same operating system on both computers?

The uni computer runs Windows 7 while my one runs Windows 10.
 

Husker86

Member
I was wondering if anyone here could point me in the right direction for what I'm after. For the last 5 years I've been working as a developer at 2 different companies using a variety of programming languages such as XBase++, C#, Java and a little bit of C++. The thing is I am completely self taught, and found it very difficult to find a job here in the UK without a degree.

The 2nd job I was in I was there for 3 years, and was pretty much made to feel very inadequate in my skill set, even though I was one of the more experienced developers on the team I was payed less than half of any university graduate starting at the company, people would look down on me for not having a degree, it's odd, but it's what happened.

As you can imagine, over the space of 3 years it was a very soul destroying experience, I lost all confidence in any programming abilities I once had entirely. The thing is this is something that I have been doing as a hobby since I was 12 years old, something I have a very strong passion for and it would be a shame to completely throw it all away.

I finally left that job last week after having a long time off due to depression it caused me and now I'm basically looking for a way for me to start from scratch. I don't really know where to begin, but I'm after some sort of resources online presented in a course like structure with assignments and such so I can build my skills back up over time and maybe move back into working in the industry. Sorry about the long whiny post but I need to get it off my chest and genuinely need some advice on how I can go forward.

Sounds like that was just a shit company (and shit coworkers to boot). I can't believe your pay was that discrepant simply because of a degree.

One thing I love about this field is the fact that you don't need a degree to prove you know what you're doing.

I'm self taught and got an Android developer job last year and the company didn't even list a degree as a requirement. My pay is inline with national averages.

Keep your head up. Again, that company doesn't sound like a good one so I wouldn't think the rest of the industry is like that. I'm in the US, but I can't imagine things are that different between countries.
 
Thanks, that's good to know. Would the SSD make a big difference if the code is stored on a HDD though? Edit: I can actually try that myself haha.



The uni computer runs Windows 7 while my one runs Windows 10.

No, if the code is stored on an HDD your SSD won't make a big difference.
 

Two Words

Member
I have an interview for a tutoring job in the CS department of my university. The area where I am mostly shakey on is structural induction. I feel like I understand the concept of structural induction, but I sometimes have trouble applying it. Here is the way I see it. If anybody things my way of thinking is lacking let me know. I am also trying to find examples with strings as well.

Structural induction is done by showing that some property holds for all of the base cases of some recursive definition and when it is assumed to be true for some arbitrary amount of recursive steps, it can be proven that the next recursive step only produces things that have that same property. It is similar to mathematic induction. You could think of k being some positive integer that represents the number of time the recursive step is applied. My problem is applying this idea to show that a set defined in set builder notation is equal to a recursive definition. I know that I must prove that each are a subset of each other and am able to do it correctly, but I sometimes find myself confused on which way I am going. I can have trouble sorting the details that are important to what I am proving. Any good examples to help with this?
 

Joe

Member
Hey guys and gals, is it possible to learn how to program for iOS in Swift language using Silver on Windows?

Is it 1:1 the same thing? I'd like to take an online iOS programming course without buying a new Mac because I'm not sure if I will even like it.
 
Hey guys and gals, is it possible to learn how to program for iOS in Swift language using Silver on Windows?

Is it 1:1 the same thing? I'd like to take an online iOS programming course without buying a new Mac because I'm not sure if I will even like it.

Oh gosh, RemObjects. I'm getting horrid flashbacks of Pascal Script. So much Pascal Script...
 

irongear

Neo Member
Hello guys, i took csce 145 this sumester and i am completely new to programming (we are using java) and i got a new homework but this time i am not sure what to do so i am hoping you all can give me some sort of advice.

This is the homework: Create a program which prompts the user to enter a time in "Hour:Minute" format and then prompts the user to enter a value, in minutes, that will add to that time. Once the calculation is completed output the resulting time.

*This is assumed to be in military time, so make sure that there is only 24 hours (0-23), 60 minutes (0-59) in any given time.

*Take a variety of inputs as long as it is in the format "Hour:Minute" (06:02 and 6:2 are both valid inputs)

*Output the original time along with the new time

the example dialog should be like this
Enter a time in the format hour:minute
3:30
Enter a number of minutes to add to this time
50
The time 50 minutes after 3:30 will be 4:20
 

Ahnez

Member
Hello guys, i took csce 145 this sumester and i am completely new to programming (we are using java) and i got a new homework but this time i am not sure what to do so i am hoping you all can give me some sort of advice.

This is the homework: Create a program which prompts the user to enter a time in "Hour:Minute" format and then prompts the user to enter a value, in minutes, that will add to that time. Once the calculation is completed output the resulting time.

*This is assumed to be in military time, so make sure that there is only 24 hours (0-23), 60 minutes (0-59) in any given time.

*Take a variety of inputs as long as it is in the format "Hour:Minute" (06:02 and 6:2 are both valid inputs)

*Output the original time along with the new time

the example dialog should be like this
Enter a time in the format hour:minute
3:30
Enter a number of minutes to add to this time
50
The time 50 minutes after 3:30 will be 4:20

But what are you having problems with? The calculation logic, reading the input?
 

dabig2

Member
Hello guys, i took csce 145 this sumester and i am completely new to programming (we are using java) and i got a new homework but this time i am not sure what to do so i am hoping you all can give me some sort of advice.

This is the homework: Create a program which prompts the user to enter a time in "Hour:Minute" format and then prompts the user to enter a value, in minutes, that will add to that time. Once the calculation is completed output the resulting time.

*This is assumed to be in military time, so make sure that there is only 24 hours (0-23), 60 minutes (0-59) in any given time.

*Take a variety of inputs as long as it is in the format "Hour:Minute" (06:02 and 6:2 are both valid inputs)

*Output the original time along with the new time

the example dialog should be like this
Enter a time in the format hour:minute
3:30
Enter a number of minutes to add to this time
50
The time 50 minutes after 3:30 will be 4:20
I'm assuming you need help with the calculations? If so, continue reading.

Are you allowed to use library functions? If yes, then just use the LocalDateTime class. It has a "plusMinutes" method that literally does all the work for you.
https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html

But that's boring. If you want to flex that brain matter, there's a few brute force ways of achieving the same thing without using built-in stuff. Just use simple math and the fact that 60 minutes = 1 hour. For example, you could convert the time they input into minutes passed since midnight.

Taking 3:30 becomes (3 hours * 60 minutes/hour) + 30 minutes = 210 minutes
Now, add your 50 minutes to that to get a new time of 260 minutes.

Now simply convert that 260 minutes back into HH:MM form like so:
1)Get the hour part: 260 minutes * (1hour/60minutes) = 4.3333 hours and then just discard the decimal to get an hour of 4.

2) Get the minutes part which is merely a remainder: 260 minutes - (4 hours * 60 minutes/hour) = 20 minutes
And voila. 4:20

Another example:
Add 300 minutes to 18:50

(18 * 60) + 50 = 1130
1130 + 300 = 1430
1430 / 60 ~ 23
1430 - (23 * 60) = 50
SO new time of 23:50

But here's some extra thought for you to consider - what happens if the minutes you add to the time eclipses the 24 hour period for that day? For example, 350 minutes to that last example gives you 24:40 which is impossible as there's only 24 hours in a day. I'll let you ruminate on that, but even that is really easy if you've followed along the simple procedure here.
 
You could try Swift on Linux.

You might be able to learn some Swift this way but you won't learn much about developing iOS apps because you want have access to the Core APIs for iOS.

Hey guys and gals, is it possible to learn how to program for iOS in Swift language using Silver on Windows?

Is it 1:1 the same thing? I'd like to take an online iOS programming course without buying a new Mac because I'm not sure if I will even like it.

It certainly appears that they are using some sort of code translation if you write your app in C# to translate it to Swift, or letting you write your app logic in Swift and doing some under the hood translation if you decide to port to other platforms. You wouldn't be able to deploy to an iOS device without a Mac though so I don't know how far you could really get with this if you were only targeting iOS devices.

Out of curiosity I'm gonna download it, I'll try to remember to report back sometime this weekend after I've had a chance to tinker with it.
 

ElTorro

I wanted to dominate the living room. Then I took an ESRAM in the knee.
After having used Scala for the last couple of months, going back to Java for a new project feels bad. The language is so terribly verbose compared to Scala. At least, the project uses Java 8.
 

vypek

Member
Are there any general good tips on being a better software engineer? I feel like I am improving at work but nowhere near as fast as I would like to be. Is this just the kind of thing that happens over time with more experience?
 

Antagon

Member
Are there any general good tips on being a better software engineer? I feel like I am improving at work but nowhere near as fast as I would like to be. Is this just the kind of thing that happens over time with more experience?

For me, it's learning how to not just write applications that not just implement the specs, but are also robust and relatively easy to maintain. Some things that help me get better at this are:

* SOLID principles
* Unit testing / TDD
* Refactoring
* Design patterns

Nothing about this is particularly original, these are all popular in OO/Java land. But they definitely help a lot.

A couple of popular and very useful books:

Clean code (Robert C. Martin)
Refactoring (Martin Fowler)
Head first design patterns
 
Are there any general good tips on being a better software engineer? I feel like I am improving at work but nowhere near as fast as I would like to be. Is this just the kind of thing that happens over time with more experience?

Choose the job that has you working on software used by the most people. #1 thing you can do to be a better engineer.

1,000 people using your software? Leave now and find a new job.
10,000 people? Get that resumes ready but take your time.
100,000 people? You could probably stay in a jb like this for a while and be ok. This is like getting a C in class. Not great, not horrible.
1,000,000 people? Now you're getting somewhere. This is likely a fine job and you will be ahead of the game in your career.
1,000,000,000? Rejoice, you are on the path to becoming a world class engineer.

I know you want to hear about books you can read and skills you can learn, but honestly nothing makes you better than getting experience working at scale.
 
Choose the job that has you working on software used by the most people. #1 thing you can do to be a better engineer.

1,000 people using your software? Leave now and find a new job.
10,000 people? Get that resumes ready but take your time.
100,000 people? You could probably stay in a jb like this for a while and be ok. This is like getting a C in class. Not great, not horrible.
1,000,000 people? Now you're getting somewhere. This is likely a fine job and you will be ahead of the game in your career.
1,000,000,000? Rejoice, you are on the path to becoming a world class engineer.

I know you want to hear about books you can read and skills you can learn, but honestly nothing makes you better than getting experience working at scale.
So... people who work on simulations don't work at scale? Flight software? HPC?

I guess I have some problems with this guideline...


But I'll offer my own advice. IMO, these are the two most important things an engineer can have (beyond the intelligence to get in the door):
1. curiosity
2. tenacity

#1 to find problems outside the scope of your knowledge (at the edge, hopefully), and #2 to butt your head against them until you solve them. Rinse, repeat, you'll get better as long as you keep working at it.
 
So... people who work on simulations don't work at scale? Flight software? HPC?

I guess I have some problems with this guideline...


But I'll offer my own advice. IMO, these are the two most important things an engineer can have (beyond the intelligence to get in the door):
1. curiosity
2. tenacity

#1 to find problems outside the scope of your knowledge (at the edge, hopefully), and #2 to butt your head against them until you solve them. Rinse, repeat, you'll get better as long as you keep working at it.

A->B doesn't mean ~A -> ~B. My premise is "Working on software used by more people will make you a better engineer". That doesn't mean nothing else will, it just means that's the best way (IMO)
 

Slavik81

Member
A->B doesn't mean ~A -> ~B. My premise is "Working on software used by more people will make you a better engineer". That doesn't mean nothing else will, it just means that's the best way (IMO)
Why? Because it's less likely for mistakes to go unnoticed? Because costs are proportionally smaller, so you can afford better design, better tools and better training? Or something else?
 
Why? Because it's less likely for mistakes to go unnoticed? Because costs are proportionally smaller, so you can afford better design, better tools and better training? Or something else?

Because the quality of every line of code you write matters more when a billion people are using your software as opposed to 100,000. You learn better practices. More defensive coding. Better testing practices.

Tools get better, infrastructure gets better. Writing something that works for 100,000 people is harder than writing something that works for 10,000 people just like writing something that works for 1 billion people is harder than writing something that works for 1 million. More configurations to support, more malware on peoples' machines you have to fight against, everything you do has more impact and is more important. When you get to a few hundred million, the "this should literally never happen" type problems becomes the norm instead of the exception.

More users typically means more money is on the line, and projects which are more valuable get more funding. A side effect of this is that everyone else around you is also better (both smarter and more experienced) so in addition to being in an environment where you have more impact, you're also around smarter people with more opportunities not just to learn, but to grow professionally. Maybe you used to be a senior staff engineer at your previous company and you had essentially capped out, you were one of the best guys there. And then you move to a company where the software is more valuable, more important, and used by more people and you find out lots of people were at your level at previous companies, and now they're just regular engineers. And the senior guys at this company are way smarter. They had no equivalent at your previous company.

My experience is obviously limited to the fields I've worked in, but this pattern has been very consistent in my ~15 years (edit: shit I'm old. 20 years). First company I worked out we had maybe 5,000 users and it's gone up an order of magnitude every few years as I've changed companies, and the pattern has always been very consistent and noticeable at each big jump.
 

Two Words

Member
I had my interview for the computer science mentor center at my university today. It went well and I'm hopeful to get the job. I had a good conversation with one of the professors. He brought up a thing called the "imposter syndrome". Basically, it is the feeling that you are undeserving of the accolades and accomplishments attributed to you. He talked about it is a common experience for CS majors and I can definitely resonate with that feelings sometimes. How much do you guys experience it in your professional environments?
 
I had my interview for the computer science mentor center at my university today. It went well and I'm hopeful to get the job. I had a good conversation with one of the professors. He brought up a thing called the "imposter syndrome". Basically, it is the feeling that you are undeserving of the accolades and accomplishments attributed to you. He talked about it is a common experience for CS majors and I can definitely resonate with that feelings sometimes. How much do you guys experience it in your professional environments?

Over 80% of people at my company have / had imposter syndrome. I'm sure it depends on the company but it's definitely real
 

vypek

Member
For me, it's learning how to not just write applications that not just implement the specs, but are also robust and relatively easy to maintain. Some things that help me get better at this are:

* SOLID principles
* Unit testing / TDD
* Refactoring
* Design patterns

Nothing about this is particularly original, these are all popular in OO/Java land. But they definitely help a lot.

A couple of popular and very useful books:

Clean code (Robert C. Martin)
Refactoring (Martin Fowler)
Head first design patterns

Choose the job that has you working on software used by the most people. #1 thing you can do to be a better engineer.

1,000 people using your software? Leave now and find a new job.
10,000 people? Get that resumes ready but take your time.
100,000 people? You could probably stay in a jb like this for a while and be ok. This is like getting a C in class. Not great, not horrible.
1,000,000 people? Now you're getting somewhere. This is likely a fine job and you will be ahead of the game in your career.
1,000,000,000? Rejoice, you are on the path to becoming a world class engineer.

I know you want to hear about books you can read and skills you can learn, but honestly nothing makes you better than getting experience working at scale.

Thanks :) I appreciate the responses

I had my interview for the computer science mentor center at my university today. It went well and I'm hopeful to get the job. I had a good conversation with one of the professors. He brought up a thing called the "imposter syndrome". Basically, it is the feeling that you are undeserving of the accolades and accomplishments attributed to you. He talked about it is a common experience for CS majors and I can definitely resonate with that feelings sometimes. How much do you guys experience it in your professional environments?

I've only been programming as a profession for a relatively short time but I definitely feel it every now and then
 
After having used Scala for the last couple of months, going back to Java for a new project feels bad. The language is so terribly verbose compared to Scala. At least, the project uses Java 8.

Urgh, I'm in the same boat. Everything becomes so damn long, especially, if you want to make variables immutable.
I miss case classes.
 

Aureon

Please do not let me serve on a jury. I am actually a crazy person.
Over 80% of people at my company have / had imposter syndrome. I'm sure it depends on the company but it's definitely real

Honestly if you don't, the place you're working at is shit.
Or you're a self-important asshole.
(Or you finally got over it, since it's years and years you work in the field, i guess)
 

JeTmAn81

Member
I think the more you learn the less likely you are to feel like an impostor but if you ever feel like you've got it all down your name better be Dennis Ritchie or something.
 

Buggy Loop

Gold Member
Guys, im having trouble with C++ object oriented.

I have a class library, class member, class book, class loan.

In library.h i have :
Code:
class Library
{
	const unsigned short NB_MEMBER_MAX = 100;
	const unsigned short NB_BOOK_MAX = 1000;
	const unsigned short NB_LOAD_MAX = 200;

public:
	Library();
	~Library();

	//Methods
	void addMember(Member);
	void removeMember(const string&);
	void addBook(Book*);
	void removeBook(const string&);
	void findTitle(const string&);
	void findCode(const string&);
	bool loan(const string&, const string&, unsigned int);
	bool returnBook(const string&, const string&);
	void infoMember(const string&);

private:
	Member** arrayMember_;		//Aggregation
	unsigned int  nbMember_;
	Book** arrayBook_;			//Aggregation
	unsigned int nbBook_;
	Loan** arrayLoan_;		//Composition
	unsigned int nbLoan_;
};

In Library.cpp, the build for dynamic allocation pointer arrays would be this

Code:
Library::Library() {
	arrayMember_ = new Member*[NB_MEMBER_MAX];
	for (int i = 0; i < NB_MEMBER_MAX; i++)
		arrayMember_[i] = nullptr;
	nbMember = 0;

	arrayBook_ = new Book*[NB_BOOK_MAX]; 
	for (int i = 0; i < NB_BOOK_MAX; i++)
		arrayBook_[i] = nullptr;
	nbBook_ = 0;

	arrayLoan_ = new Loan*[NB_LOAN_MAX];
	for (int i = 0; i < NB_LOAN_MAX; i++)
		arrayLoan_[i] = nullptr;
	nbLoan_ = 0;
}

Library::~Library() {
	for (int i = 0; i < NB_MEMBER_MAX; i++) {
		if (arrayMember_ != nullptr) {
			delete arrayMember_[i];
			arrayMember_[i] = nullptr;
		}
	}
	delete[] arrayMember_;
	arrayMember_ = nullptr;

	for (int i = 0; i < NB_BOOK_MAX; i++) {
		if (arrayBook_ != nullptr) {
			delete arrayBook_[i];
			arrayBook_[i] = nullptr;
		}
	}
	delete[] arrayBook_;
	arrayBook_ = nullptr;

	for (int i = 0; i < NB_LOAN_MAX; i++) {
		if (arrayLoan_ != nullptr) {
			delete arrayLoan_[i];
			arrayLoan_[i] = nullptr;
		}
	}
	delete[] arrayLoan_;
	arrayLoan_ = nullptr;
}

... and much more code in library...

Now, can we even determine composition/aggregation from that? Because this seems like the only way of making a dynamic array of pointers that i know of.

Could it be from the main? we create the members and books in main, and then create the library and add them.

Code:
int main()
{
	
	Member a1 = Member("1839456", "Doe", "John", 23);
	Book* b1 = new Book("GA403", "Big C++", 2009, 8, 3);
...

I thought composition/aggregation had to be within the class and not the main?
 

Slavik81

Member
I trust the authors of the argon2 C library. It's new, but has been carefully reviewed. Unfortunately, the author of the recommended javascript bindings for the library appears to have made a few mistakes in terminology. I believe I encountered a bug as well. Given that it handles passwords, I want to be sure those issues are not indicative of deeper problems with the integration.

The bindings consist of a couple hundred lines of C++ code. Spending a few hours checking them in detail is both a matter of personal interest, and a decent way to give back to the community.
So, here's my contribution. I think it more than makes up for my whining about poor documentation for node community libraries.

Unfortunately, I can't recommend node-argon2 to anyone. Hopefully somebody more experienced steps up to help maintain node bindings for argon2. In the meantime, I think I'll just use bcrypt try to help, though ideally someone more experienced in this area would step up.
 

Trident

Loaded With Aspartame
Guys, im having trouble with C++ object oriented.

I have a class library, class member, class book, class loan.

In library.h i have :
Code:
class Library
{
	const unsigned short NB_MEMBER_MAX = 100;
	const unsigned short NB_BOOK_MAX = 1000;
	const unsigned short NB_LOAD_MAX = 200;

public:
	Library();
	~Library();

	//Methods
	void addMember(Member);
	void removeMember(const string&);
	void addBook(Book*);
	void removeBook(const string&);
	void findTitle(const string&);
	void findCode(const string&);
	bool loan(const string&, const string&, unsigned int);
	bool returnBook(const string&, const string&);
	void infoMember(const string&);

private:
	Member** arrayMember_;		//Aggregation
	unsigned int  nbMember_;
	Book** arrayBook_;			//Aggregation
	unsigned int nbBook_;
	Loan** arrayLoan_;		//Composition
	unsigned int nbLoan_;
};

In Library.cpp, the build for dynamic allocation pointer arrays would be this

Code:
Library::Library() {
	arrayMember_ = new Member*[NB_MEMBER_MAX];
	for (int i = 0; i < NB_MEMBER_MAX; i++)
		arrayMember_[i] = nullptr;
	nbMember = 0;

	arrayBook_ = new Book*[NB_BOOK_MAX]; 
	for (int i = 0; i < NB_BOOK_MAX; i++)
		arrayBook_[i] = nullptr;
	nbBook_ = 0;

	arrayLoan_ = new Loan*[NB_LOAN_MAX];
	for (int i = 0; i < NB_LOAN_MAX; i++)
		arrayLoan_[i] = nullptr;
	nbLoan_ = 0;
}

Library::~Library() {
	for (int i = 0; i < NB_MEMBER_MAX; i++) {
		if (arrayMember_ != nullptr) {
			delete arrayMember_[i];
			arrayMember_[i] = nullptr;
		}
	}
	delete[] arrayMember_;
	arrayMember_ = nullptr;

	for (int i = 0; i < NB_BOOK_MAX; i++) {
		if (arrayBook_ != nullptr) {
			delete arrayBook_[i];
			arrayBook_[i] = nullptr;
		}
	}
	delete[] arrayBook_;
	arrayBook_ = nullptr;

	for (int i = 0; i < NB_LOAN_MAX; i++) {
		if (arrayLoan_ != nullptr) {
			delete arrayLoan_[i];
			arrayLoan_[i] = nullptr;
		}
	}
	delete[] arrayLoan_;
	arrayLoan_ = nullptr;
}

... and much more code in library...

Now, can we even determine composition/aggregation from that? Because this seems like the only way of making a dynamic array of pointers that i know of.

Could it be from the main? we create the members and books in main, and then create the library and add them.

Code:
int main()
{
	
	Member a1 = Member("1839456", "Doe", "John", 23);
	Book* b1 = new Book("GA403", "Big C++", 2009, 8, 3);
...

I thought composition/aggregation had to be within the class and not the main?

Is there a reason you're using c style arrays instead of std::vectors?
 

ssharm02

Banned
guys i have question about splitting a string in java.

User enters a string in java, I have to split it into different components.


Code:
Scanner scanner = new Scanner(System.in);
      String test = scanner.next();
       
       
       // split the test variable using the split method
        String [] parts = test.split(" ,", 3);
        
        s[i].setFirstName(parts[0].trim());
        s[i].setlastName(parts[1].trim());
        s[i].setID(Integer.parseInt(parts[2].trim()));
        s[i].setgrade(Integer.parseInt(parts[3].trim()));

but its not working! I tried various test programs but i can only get the first word to show up. Please help
 

Antagon

Member
guys i have question about splitting a string in java.

User enters a string in java, I have to split it into different components.


Code:
Scanner scanner = new Scanner(System.in);
      String test = scanner.next();
       
       
       // split the test variable using the split method
        String [] parts = test.split(" ,", 3);
        
        s[i].setFirstName(parts[0].trim());
        s[i].setlastName(parts[1].trim());
        s[i].setID(Integer.parseInt(parts[2].trim()));
        s[i].setgrade(Integer.parseInt(parts[3].trim()));

but its not working! I tried various test programs but i can only get the first word to show up. Please help

It's hard to help if you don't give an example of the input. But first thing I notice is that you've got a space in front of the comma, sure that's correct?
 
Top Bottom