CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Search:

Type: Posts; User: Hermit

Page 1 of 24 1

1. ## Thread: having trouble writing a recursive algorithm for 2^n

by Hermit
Replies
3
Views
736

### Re: having trouble writing a recursive algorithm for 2^n

Just think about it algebraically:

2^n = 2^(n-1) + 2^(n-1) = 2 * 2^(n-1)
x(n) = 2^n
x(n) = 2 * x(n-1)

Make sense? I haven't written any code and I still feel like I'm giving away the answer.
2. ## Thread: Encryption using a Genetic Algorithm?

by Hermit
Replies
11
Views
3,823

### Re: Encryption using a Genetic Algorithm?

I don't think it's meant to make the key "more secure" with regard to brute force methods, but to make the cyphertext less easily analyzed by mathematical or intuitive means. At the risk of revealing...
3. ## Thread: Size_t Weird Bug within Loop

by Hermit
Replies
20
Views
1,927

### Re: Size_t Weird Bug within Loop

A good point. Certainly one could limit the variable's scope with an extra pair of curly braces, but that would be a bit on the ugly side, and not something I can honestly say that I do. I had read...
4. ## Thread: Size_t Weird Bug within Loop

by Hermit
Replies
20
Views
1,927

### Re: Size_t Weird Bug within Loop

Agreed that it's odd. If I must write a loop that breaks form like that, I tend to prefer writing it as a while-loop. I don't think anyone should have to take a second look at a for-loop to see what...
5. ## Thread: Why Non Member Function cannot declared with const ?

by Hermit
Replies
5
Views
1,588

### Re: Why Non Member Function cannot declared with const ?

In other words, recall that member functions are implicitly passed a this-pointer when called. When you declare a member function as const, you are specifying the constness of that implicit...
6. ## Thread: Memory Leak Questions

by Hermit
Replies
24
Views
3,321

### Re: Memory Leak Questions

I don't think it's fair to assume that the OP is still in the beginning stages of his education, so the topic should have little to do with that. If this is a project for an introductory course, I'm...
7. ## Thread: Addressof Unary Functor

by Hermit
Replies
9
Views
5,659

### Re: Addressof Unary Functor

You may want to have a look at boost's ptr_vector class. It will, by default, automatically delete pointers when they are removed from the container.

Another option would be to use a vector of...
8. ## Thread: Addressof Unary Functor

by Hermit
Replies
9
Views
5,659

### Re: Addressof Unary Functor

None that I'm aware of.
Seems fine to me. It did seem a bit odd that you would create a second array of pointers to every element in another array, but then I saw the last part of your post. You...
9. ## Thread: self-referencing policies

by Hermit
Replies
12
Views
1,240

### Re: self-referencing policies

This still doesn't make any sense. In order for the policy class to resolve T::fooType, T needs to be a complete type, which it can't be because at this point in the instantiation we're still...
10. ## Thread: Heap efficiency?

by Hermit
Replies
65
Views
6,181

### Re: Heap efficiency?

I feel I need to point out that while you criticize _uj for his acerbic posting style, saying that it detracts from the informational content of the thread, you yourself have contributed nothing...
11. ## Thread: What void foo() is really? - a Method? OR a Function?

by Hermit
Replies
23
Views
4,084

### Poll: Re: What void foo() is really? - a Method? OR a Function?

I would subscribe to Lindley's definition if it lacked the word "objects", which causes it to disagree with the term "static method". To its credit, however, that definition does underscore an...
12. ## Thread: C++ randomizing string help

by Hermit
Replies
17
Views
3,531

### Re: C++ randomizing string help

You should be aware that the algorithm you're proposing is, in a word, slow. Consider the word "algorithm", of which there are 9! = 36,2880 permutations. Would you want to take each of those...
13. ## Thread: Getting input from Soundcard

by Hermit
Replies
4
Views
1,322

### Re: Getting input from Soundcard

Portaudio is a pretty good cross-platform sound library that you could use. If you're a novice programmer and don't want to muck about with a separate thread for audio, this library is particularly...
14. ## Thread: I need help with this simple calculation!!!

by Hermit
Replies
17
Views
2,096

### Re: I need help with this simple calculation!!!

In the code you posted, you do not divide by div1, you divide by div and store the result in div1. You then output the value of the uninitialized variable divided. Uninitialized variables may...
15. ## Thread: need help with a c++ program :(

by Hermit
Replies
6
Views
943

### Re: need help with a c++ program :(

Change
while (int j=0;j<counter;j++)
to

for (int j=0;j<counter;j++)
16. ## Thread: Reference Counting

by Hermit
Replies
16
Views
2,225

### Re: Reference Counting

This isn't a question.

Cyclic referencing is partially solved by using weak pointers where appropriate, which are convertible to and from shared pointers but do not by themselves increase the...
17. ## Thread: Uniquely Identifying a PC

by Hermit
Replies
3
Views
1,062

### Re: Uniquely Identifying a PC

I've seen a few licensing systems use the MAC address of the ethernet adaptor. A quick search brought up this article on getting MAC addresses (Windows-specific).
18. ## Thread: Memory clear for time testing in c++

by Hermit
Replies
4
Views
849

### Re: Memory clear for time testing in c++

What do you mean by "clear memory"? Free the memory reserved by a vector? One way that's often accomplished is what's called the swap trick:

std::vector<double> lots_of_data(5000);
...
19. ## Thread: GUI Programming In C++?

by Hermit
Replies
6
Views
994

### Re: GUI Programming In C++?

Cocoa is an Objective-C framework (could they have picked an uglier language?), although it is possible to incorporate C++ code into a Cocoa application (using "Objective-C++" as its called). Carbon...
20. ## Thread: Finding orthogonal vector

by Hermit
Replies
1
Views
6,610

### Finding orthogonal vector

This is a bit of a math question, but I'll ask it here partly because I don't belong to any math forums, and partly because the computational complexity of the answer is important.

Given two...
21. ## Thread: A 'final' C++ class

by Hermit
Replies
3
Views
838

### Re: A 'final' C++ class

Yeah, it's doable. I can't seem to find the article but the technique involves virtually inheriting from a class whose constructor is private and which declares the "final" class as a friend. This...
22. ## Thread: static constant - non integral type

by Hermit
Replies
2
Views
1,053

### Re: static constant - non integral type

The problem here is simply that dbar_val is declared const but defined non-const. Change that line to:

const double bar::dbar_val = 3.1233;
Note you could also do:

class bar {
static...
23. ## Thread: private members not so private.

by Hermit
Replies
16
Views
1,939

### Re: private members not so private.

The conclusion is that C++ will not keep you from shooting yourself in the foot if you are hell-bent on doing so. Compiler rules exist to keep sane programmers from making mistakes, not to keep...
24. ## Thread: Template specialisation of template class member function

by Hermit
Replies
21
Views
2,043

### Re: Template specialisation of template class member function

Well, it's a debatable point, depending on what kind of guarantee you're looking for. The current standard does not require that strings be contiguous, but future standards will and most if not all...
25. ## Thread: Template specialisation of template class member function

by Hermit
Replies
21
Views
2,043

### Re: Template specialisation of template class member function

I do not think it is safe to assume that all random access iterators will iterate over contiguous memory, just that they provide constant-time access to any element in the collection. If a random...
Results 1 to 25 of 581
Page 1 of 24 1

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)