• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 15:01
CET 21:01
KST 05:01
  • 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
TL.net Map Contest #21: Winners1Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
Starcraft, SC2, HoTS, WC3, returning to Blizzcon!20$5,000+ WardiTV 2025 Championship5[BSL21] RO32 Group Stage3Weekly Cups (Oct 26-Nov 2): Liquid, Clem, Solar win; LAN in Philly2Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win9
StarCraft 2
General
TL.net Map Contest #21: Winners Starcraft, SC2, HoTS, WC3, returning to Blizzcon! RotterdaM "Serral is the GOAT, and it's not close" Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win 5.0.15 Patch Balance Hotfix (2025-10-8)
Tourneys
$5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest Merivale 8 Open - LAN - Stellar Fest Sea Duckling Open (Global, Bronze-Diamond) $3,500 WardiTV Korean Royale S4
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection Mutation # 495 Rest In Peace
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ SnOw's ASL S20 Finals Review [BSL21] RO32 Group Stage Practice Partners (Official) [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[Megathread] Daily Proleagues [BSL21] RO32 Group B - Sunday 21:00 CET [BSL21] RO32 Group A - Saturday 21:00 CET BSL21 Open Qualifiers Week & CONFIRM PARTICIPATION
Strategy
Current Meta How to stay on top of macro? PvZ map balance Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Dawn of War IV ZeroSpace Megathread General RTS Discussion Thread
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
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine YouTube Thread Dating: How's your luck?
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Why we need SC3
Hildegard
Career Paths and Skills for …
TrAiDoS
Reality "theory" prov…
perfectspheres
Our Last Hope in th…
KrillinFromwales
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1327 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 States17264 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 States17264 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 States17264 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
LAN Event
18:00
Day 3: Ursa 2v2, FFA
SteadfastSC341
IndyStarCraft 173
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 461
SteadfastSC 341
IndyStarCraft 173
White-Ra 151
UpATreeSC 149
ProTech122
Railgan 44
MindelVK 34
ROOTCatZ 15
StarCraft: Brood War
Shuttle 454
BRAT_OK 69
scan(afreeca) 32
Shine 7
ivOry 5
Dota 2
qojqva3461
Dendi1022
Counter-Strike
pashabiceps824
Heroes of the Storm
Liquid`Hasu247
Other Games
FrodaN1350
fl0m758
Beastyqt582
Mlord517
ceh9442
KnowMe194
ArmadaUGS173
C9.Mang092
Mew2King77
Trikslyr55
shahzam7
OptimusSC21
Organizations
Counter-Strike
PGL125
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 20 non-featured ]
StarCraft 2
• Reevou 13
• Adnapsc2 9
• Dystopia_ 0
• Kozan
• sooper7s
• AfreecaTV YouTube
• Migwel
• LaughNgamezSOOP
• intothetv
• IndyKCrew
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2940
• Ler90
League of Legends
• Nemesis2245
• TFBlade918
Other Games
• imaqtpie1157
• WagamamaTV313
• Shiphtur223
Upcoming Events
OSC
1h 59m
Replay Cast
2h 59m
OSC
15h 59m
LAN Event
18h 59m
Korean StarCraft League
1d 6h
CranKy Ducklings
1d 13h
LAN Event
1d 18h
IPSL
1d 21h
dxtr13 vs OldBoy
Napoleon vs Doodle
BSL 21
1d 23h
Gosudark vs Kyrie
Gypsy vs Sterling
UltrA vs Radley
Dandy vs Ptak
Replay Cast
2 days
[ Show More ]
Sparkling Tuna Cup
2 days
WardiTV Korean Royale
2 days
LAN Event
2 days
IPSL
2 days
JDConan vs WIZARD
WolFix vs Cross
BSL 21
2 days
spx vs rasowy
HBO vs KameZerg
Cross vs Razz
dxtr13 vs ZZZero
Replay Cast
3 days
Wardi Open
3 days
WardiTV Korean Royale
4 days
Replay Cast
5 days
Kung Fu Cup
5 days
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
Tenacious Turtle Tussle
6 days
The PondCast
6 days
RSL Revival
6 days
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
6 days
WardiTV Korean Royale
6 days
Liquipedia Results

Completed

BSL 21 Points
SC4ALL: StarCraft II
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025

Upcoming

BSL Season 21
SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
Stellar Fest
META Madness #9
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
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 © 2025 TLnet. All Rights Reserved.