Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 07-09-2004, 02:49 AM   #1
Member (10 bit)
 
Join Date: Jul 2002
Location: University of California, Santa Barbara
Posts: 800
C++, Returning a boolean array

In C++ I want to write a function which returns a boolean array, but I can't seem to do it as either a return value, or a reference parameter. Is there any way I can do it without resorting to a global variable?
mattg2k4 is offline   Reply With Quote
Old 07-09-2004, 07:02 AM   #2
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
How I usually do it:

Code:
#include <iostream>
                                                                                
void func(bool* array) {
    array[0] = true;
    // ...
}
                                                                                
int main(void) {
    bool arr[10];
    func(arr);
    std::cout << arr[0];
    return 0;
}
aym is offline   Reply With Quote
Old 07-10-2004, 10:42 PM   #3
Member (10 bit)
 
Join Date: Jul 2002
Location: University of California, Santa Barbara
Posts: 800
Thanks for the tip.
mattg2k4 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 06:49 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2