• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 05:59
CET 11:59
KST 19:59
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
HomeStory Cup 28 - Info & Preview12Rongyi Cup S3 - Preview & Info3herO wins SC2 All-Star Invitational14SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8
Community News
Weekly Cups (Jan 26-Feb 1): herO, Clem, ByuN, Classic win2RSL Season 4 announced for March-April6Weekly Cups (Jan 19-25): Bunny, Trigger, MaxPax win3Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion8
StarCraft 2
General
StarCraft 2 Not at the Esports World Cup 2026 Weekly Cups (Jan 26-Feb 1): herO, Clem, ByuN, Classic win HomeStory Cup 28 - Info & Preview Weekly Cups (Jan 19-25): Bunny, Trigger, MaxPax win Oliveira Would Have Returned If EWC Continued
Tourneys
PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) HomeStory Cup 28 StarCraft Evolution League (SC Evo Biweekly) RSL Season 4 announced for March-April $21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)
Strategy
Custom Maps
[A] Starcraft Sound Mod
External Content
Mutation # 511 Temple of Rebirth The PondCast: SC2 News & Results Mutation # 510 Safety Violation Mutation # 509 Doomsday Report
Brood War
General
BW General Discussion Can someone share very abbreviated BW cliffnotes? [ASL21] Potential Map Candidates Liquipedia.net NEEDS editors for Brood War BGH Auto Balance -> http://bghmmr.eu/
Tourneys
Azhi's Colosseum - Season 2 [Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL21] Non-Korean Championship - Starts Jan 10
Strategy
Zealot bombing is no longer popular? Simple Questions, Simple Answers Current Meta Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Nintendo Switch Thread Battle Aces/David Kim RTS Megathread Path of Exile Mobile Legends: Bang Bang Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine European Politico-economics QA Mega-thread The Games Industry And ATVI Canadian Politics Mega-thread
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Play, Watch, Drink: Esports …
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2112 users

The Big Programming Thread - Page 294

Forum Index > General Forum
Post a Reply
Prev 1 292 293 294 295 296 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Orome
Profile Blog Joined June 2004
Switzerland11984 Posts
May 02 2013 16:29 GMT
#5861
Ah damn I found it. I used heap.reserve(capacity), but I believe that only reserves space for pointers? And I'm storing the actual elements in the heap? In any case, with a normal declaration of the size of the heap, everything works out.
On a purely personal note, I'd like to show Yellow the beauty of infinitely repeating Starcraft 2 bunkers. -Boxer
Zeke50100
Profile Blog Joined February 2010
United States2220 Posts
Last Edited: 2013-05-02 16:33:24
May 02 2013 16:31 GMT
#5862
On May 03 2013 01:17 Orome wrote:
Hey guys, was hoping someone could help me out again real quick. I'm trying to make a vector-based heap of std:: pairs. My solution seems to be identical to the one they provided us with, but somehow it doesn't work. When I try to do something like this:


heap[1] = item(k, e);


the program crashes.

item is defined as:

typedef std::pair<int, string> item;

heap's a class variable, defined as:

std::vector<item> heap;


I appreciate any help.


EDIT: Well, you found the error, so I'll spoiler the old answer.
+ Show Spoiler +
I suspect an out-of-bounds error: a std::vector does not have any "space" upon construction - its size dynamically grows as you need to add new stuff to it (or shrinks if you're taking things out of it).

heap[1] = item(k, e)

heap[1] is out-of-bounds because there isn't a [1] in heap.

std::pair<int, std::string> item(5, "apple pie");
std::vector<std::pair<int, std::string> > heap;
heap.push_back(item);


The "push_back()" function adds an object to the heap. After having added the item, you can now access it as "heap[indexNumber]" - in this case, "heap[0]" will let you access (5, "apple pie"). Alternatively:

std::vector<item> heap(10)


This will leave you with 10 default-constructed items (in this case, pairs of ints and strings).

std::cout << heap[0].second << '\n'; //will print "apple pie"
std::cout << heap[1].second << '\n'; //undefined behavior if the size of heap is less than 2
std::cout << heap.at(0).second << '\n'; //will also print "applie pie"
std::cout << heap.at(1).second << '\n'; //will throw an out-of-bounds exception, so you aren't confused


The at() function can help alleviate this problem.

A useful resource on vectors is here, in case you have other issues.
Sverigevader
Profile Joined March 2010
Sweden388 Posts
May 04 2013 15:37 GMT
#5863
Quick question about operator overloading in C++.

I've written a Fraction class and I've overloaded for example the + operator to work when adding integers with fractions

Code:
+ Show Spoiler +

friend Fraction operator+ (int i, Fraction& f1);
friend Fraction operator+ (Fraction& f1, int i);


I'm sure you can figure out my question already: Is there a way to do this without having to do two separate functions for when the terms switch places?
"I can answer this, you're just a god damn sexy mofo." http://www.teamliquid.net/forum/viewmessage.php?topic_id=147829&currentpage=7#139
netherh
Profile Blog Joined November 2011
United Kingdom333 Posts
May 04 2013 16:24 GMT
#5864
On May 05 2013 00:37 Sverigevader wrote:
Quick question about operator overloading in C++.

I've written a Fraction class and I've overloaded for example the + operator to work when adding integers with fractions

Code:
+ Show Spoiler +

friend Fraction operator+ (int i, Fraction& f1);
friend Fraction operator+ (Fraction& f1, int i);


I'm sure you can figure out my question already: Is there a way to do this without having to do two separate functions for when the terms switch places?


Nope.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
May 04 2013 17:44 GMT
#5865
On May 05 2013 01:24 netherh wrote:
Show nested quote +
On May 05 2013 00:37 Sverigevader wrote:
Quick question about operator overloading in C++.

I've written a Fraction class and I've overloaded for example the + operator to work when adding integers with fractions

Code:
+ Show Spoiler +

friend Fraction operator+ (int i, Fraction& f1);
friend Fraction operator+ (Fraction& f1, int i);


I'm sure you can figure out my question already: Is there a way to do this without having to do two separate functions for when the terms switch places?


Nope.

Negatory.
ddengster
Profile Blog Joined January 2009
Singapore129 Posts
May 04 2013 17:50 GMT
#5866
On May 05 2013 00:37 Sverigevader wrote:
Quick question about operator overloading in C++.

I've written a Fraction class and I've overloaded for example the + operator to work when adding integers with fractions

Code:
+ Show Spoiler +

friend Fraction operator+ (int i, Fraction& f1);
friend Fraction operator+ (Fraction& f1, int i);


I'm sure you can figure out my question already: Is there a way to do this without having to do two separate functions for when the terms switch places?


think you can do it with template specializations, but it's not worth the amount of code. Usually, you put the operator+ function within Fraction itself so it's treated as a method of the class, so there's no need to have a second global friend function for your 2nd line of code.

example:
class Fraction
{
public:
Fraction operator+(int i);

friend Fraction operator+ (int i, Fraction& f1);
};
Check out NEO Impossible Bosses, RTS-MOBA boss rush at http://neoimpossiblebosses.coder-ddeng.com
Kambing
Profile Joined May 2010
United States1176 Posts
May 04 2013 18:03 GMT
#5867
On May 05 2013 02:50 ddengster wrote:
Show nested quote +
On May 05 2013 00:37 Sverigevader wrote:
Quick question about operator overloading in C++.

I've written a Fraction class and I've overloaded for example the + operator to work when adding integers with fractions

Code:
+ Show Spoiler +

friend Fraction operator+ (int i, Fraction& f1);
friend Fraction operator+ (Fraction& f1, int i);


I'm sure you can figure out my question already: Is there a way to do this without having to do two separate functions for when the terms switch places?


think you can do it with template specializations, but it's not worth the amount of code. Usually, you put the operator+ function within Fraction itself so it's treated as a method of the class, so there's no need to have a second global friend function for your 2nd line of code.

example:
class Fraction
{
public:
Fraction operator+(int i);

friend Fraction operator+ (int i, Fraction& f1);
};


That doesn't solve the problem of requiring two separate functions.

In general, operator+ may not be commutative, so there is no automatic support for generating both forms of the operator. The simplest way is to implement one operator directly and (either as a free-floating function as you have or as a member function as ddengster described) and then implement the other operator in terms of the first.
WindWolf
Profile Blog Joined July 2012
Sweden11767 Posts
May 04 2013 18:35 GMT
#5868
I'm looking to learn C#, does anyone have any good tips on links where I can start reading/learning.
I know how to program in C++ and I'm a rusty on Java.
EZ4ENCE
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
Last Edited: 2013-05-05 03:49:32
May 05 2013 03:44 GMT
#5869
I'm having some trouble with a simple html page. I want to link some css. Can someone take a quick look?

Crosspost on stack:

http://stackoverflow.com/questions/16381132/how-do-i-get-text-in-my-html-page-to-display-features-using-the-css-stylesheet

Figured it out. Misconfigured stylesheet link.
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
May 05 2013 18:46 GMT
#5870
What do you think of Extreme Programming methodology?

http://en.wikipedia.org/wiki/Extreme_programming
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
May 05 2013 19:41 GMT
#5871
On May 06 2013 03:46 darkness wrote:
What do you think of Extreme Programming methodology?

http://en.wikipedia.org/wiki/Extreme_programming


Depends on what part of it you mean.

Most programmers already do a lot of what extreme programming entails but going the full way has about as many problems as it has advantages, the same as most agile methodologies. The best is to do what works, to get ideas from other methodologies but to be critical and only apply the stuff that you really need and to be wary of overengineering the process instead of putting the effort into actual solutions.

There is no silver bullet.
Craton
Profile Blog Joined December 2009
United States17275 Posts
May 05 2013 20:01 GMT
#5872
Your organization has to try different methodologies and see which works the best for different types of projects (or just for your organization in general).

Mine does / has done a little bit of everything (waterfall, modified waterfall, scrum, other agile methods) and we've found pros and cons for everything (especially when working with the government).
twitch.tv/cratonz
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
May 05 2013 21:04 GMT
#5873
Alright, thanks for your thoughts. I'm not employed yet, but I have a module at university called 'Software Tools'. It defines itself as XP based, thus teaching us Ant, JUnit and Eclipse as well as the role of CASE (Computer-aided Software Engineering). I'm just curious if XP is practical in professional programming.
Craton
Profile Blog Joined December 2009
United States17275 Posts
Last Edited: 2013-05-05 21:14:53
May 05 2013 21:14 GMT
#5874
I don't find project management stuff to be very useful / important to know. Your organization should have a project / technical manager in charge of implementing and training everyone on what you're going to be doing.

If you want to be a PM/TM then that's another story, but as someone who develops and hates managerial stuff, I loathed that type of coursework.
twitch.tv/cratonz
Arnstein
Profile Blog Joined May 2010
Norway3381 Posts
May 06 2013 11:17 GMT
#5875
I have a class Creature with the protected int HP in C++. I have a subclass Enemy. Shouldn't enemy then get the int HP, as a sort of private int? I get the compiler error "class Enemy has no member named HP"

rsol in response to the dragoon voice being heard in SCII: dragoon ai reaches new lows: wanders into wrong game
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
May 06 2013 11:38 GMT
#5876
On May 06 2013 20:17 Arnstein wrote:
I have a class Creature with the protected int HP in C++. I have a subclass Enemy. Shouldn't enemy then get the int HP, as a sort of private int? I get the compiler error "class Enemy has no member named HP"



A bit harder to diagnose without knowledge of how they're implemented. Is everything defined properly?
There is no one like you in the universe.
Arnstein
Profile Blog Joined May 2010
Norway3381 Posts
May 06 2013 11:44 GMT
#5877
On May 06 2013 20:38 Blisse wrote:
Show nested quote +
On May 06 2013 20:17 Arnstein wrote:
I have a class Creature with the protected int HP in C++. I have a subclass Enemy. Shouldn't enemy then get the int HP, as a sort of private int? I get the compiler error "class Enemy has no member named HP"



A bit harder to diagnose without knowledge of how they're implemented. Is everything defined properly?


No, I fixed with the good ol' #ifndef and #define
rsol in response to the dragoon voice being heard in SCII: dragoon ai reaches new lows: wanders into wrong game
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-05-06 22:39:15
May 06 2013 22:34 GMT
#5878
I am not sure how to call it exactly, but Objective-C can do something like this:

[[person child] setHeight:argument];

Is there something similar in Java/C++? Perhaps person.child.height = argument; but is inheritance involved here? I'm not sure if I understand code above. Perhaps you use a method from another class without calling an instance?
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
Last Edited: 2013-05-06 23:12:13
May 06 2013 23:08 GMT
#5879
On May 07 2013 07:34 darkness wrote:
I am not sure how to call it exactly, but Objective-C can do something like this:

[[person child] setHeight:argument];

Is there something similar in Java/C++? Perhaps person.child.height = argument; but is inheritance involved here? I'm not sure if I understand code above. Perhaps you use a method from another class without calling an instance?

As far as Objective-C is concerned, that block of code is calling the "setHeight" function with the "argument" as a parameter on an object returned from the "child" function of the "person" object.

I don't know the Java or C++ equivalent, but essentially it's a nested function call.
Craton
Profile Blog Joined December 2009
United States17275 Posts
May 07 2013 00:20 GMT
#5880
How does one go about writing a select statement (PL/SQL) that will accomplish the following:

Assume a "lookup" table with a pair of fields "match" and "replace" that have values like: À, A; È, E (such that you have pairs of "accented" characters in the match and "normal" characters in the replace).

Assume you have another table with n number of records, any of which have one or more characters matching this pattern. The end translation should go something like ÀNYWHÈRÈ -> ANYWHERE.

For a single value, I can use a CONNECT BY LEVEL to split each character into a separate field, join to the lookup table, and then use a MODEL construct to perform the replacement and concatenation of each character (ordering maintained), taking only the final "built" value. However, I can't make it work when I have multiple values (i.e. from a table), since I can't just connect it by level.

I feel there might also be a way to skip the CONNECT BY step altogether, but I can't make it happen.

Thoughts?
twitch.tv/cratonz
Prev 1 292 293 294 295 296 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 1h 1m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 186
BRAT_OK 89
ProTech29
StarCraft: Brood War
Calm 4645
Bisu 1831
Jaedong 684
Larva 564
GuemChi 431
BeSt 332
actioN 303
Light 287
Mini 180
Dewaltoss 156
[ Show more ]
Sacsri 128
Pusan 114
Soulkey 113
Sharp 111
Soma 90
Snow 75
hero 70
Rush 70
ToSsGirL 68
sSak 61
ZerO 55
Shuttle 50
Mong 50
Backho 50
ajuk12(nOOB) 46
Killer 46
Hyuk 44
Mind 41
sorry 36
Bale 32
GoRush 27
zelot 24
Hm[arnc] 21
Terrorterran 20
Free 20
Noble 17
Movie 15
SilentControl 8
Shinee 3
Hyun 0
Dota 2
Gorgc3385
XaKoH 463
XcaliburYe97
Counter-Strike
shoxiejesuss989
allub160
Other Games
Liquid`RaSZi1128
ceh9508
B2W.Neo467
crisheroes203
Pyrionflax182
Mew2King83
KnowMe45
ToD38
ZerO(Twitch)12
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 5
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos3887
• Stunt1478
Upcoming Events
WardiTV Invitational
1h 1m
Rex vs SHIN
Rex vs MaxPax
Rex vs ShoWTimE
SHIN vs ShoWTimE
MaxPax vs SHIN
MaxPax vs ShoWTimE
Replay Cast
13h 1m
The PondCast
23h 1m
WardiTV Invitational
1d 1h
Replay Cast
1d 13h
RongYI Cup
3 days
herO vs Maru
uThermal 2v2 Circuit
4 days
Replay Cast
4 days
Wardi Open
5 days
Monday Night Weeklies
5 days
[ Show More ]
Sparkling Tuna Cup
5 days
Liquipedia Results

Completed

Proleague 2026-02-02
HSC XXVIII
Underdog Cup #3

Ongoing

CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
Acropolis #4 - TS4
Rongyi Cup S3
Nations Cup 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8

Upcoming

Escore Tournament S1: W7
Escore Tournament S1: W8
Acropolis #4
IPSL Spring 2026
HSC XXIX
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
RSL Revival: Season 4
LiuLi Cup: 2025 Grand Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.