Search found 4039 matches

by albinopapa
March 23rd, 2020, 4:56 pm
Forum: Everything
Topic: Auto cast an iterator into its base pointer type ?
Replies: 25
Views: 446

Re: Auto cast an iterator into its base pointer type ?

And all these C++ checking take some CPU times. Not sure exactly what you mean there. What checking is there in C++ that you wouldn't have in a C program? As an example in your MT project, you have public access to your condition_variable named cv in your Prog class. If you were to make a member fu...
by albinopapa
March 23rd, 2020, 12:32 am
Forum: Everything
Topic: Auto cast an iterator into its base pointer type ?
Replies: 25
Views: 446

Re: Auto cast an iterator into its base pointer type ?

I've taken a look at it and while I'm not very experienced in MT, I will see what I come up with. As for the get/set methods, they can be beneficial. Say you want to keep a value between a certain range. If the member is public, you'll always have to write clamping code everywhere you set the value....
by albinopapa
March 22nd, 2020, 4:50 pm
Forum: Everything
Topic: Auto cast an iterator into its base pointer type ?
Replies: 25
Views: 446

Re: Auto cast an iterator into its base pointer type ?

I've tried helping someone break the C habit, it wasn't easy for them. Yes. For example I use classes and methods, but at the end, I put everything in public because I want to easily access every member from anywhere... I know it's bad. :-( One of the things that this person couldn't wrap their hea...
by albinopapa
March 20th, 2020, 8:32 am
Forum: Everything
Topic: Auto cast an iterator into its base pointer type ?
Replies: 25
Views: 446

Re: Auto cast an iterator into its base pointer type ?

Ha, no sir. I wanted to "C" what it was like. I had an argument with a C programmer on a YT channel and they made the comment that C++ programmers don't know what they are talking about when it comes to C thinking that just because C++ came from C that they are still the same language. While I did f...
by albinopapa
March 19th, 2020, 7:08 am
Forum: Everything
Topic: Auto cast an iterator into its base pointer type ?
Replies: 25
Views: 446

Re: Auto cast an iterator into its base pointer type ?

try to escape from my old C habits, it's not always a success
I've tried helping someone break the C habit, it wasn't easy for them.
by albinopapa
March 16th, 2020, 3:37 pm
Forum: Everything
Topic: Trying the Snek game again, small issue.
Replies: 5
Views: 242

Re: Trying the Snek game again, small issue.

Lol, well I'm surprised that worked for you, because what I was actually pointing out was

for (int i = 0; i < segNo; i++)

probably should have been

for (int i = 0; i < segIndex; i++)

segNo is a constant 200 and you only want to iterate through the segments that are spawned.
by albinopapa
March 14th, 2020, 6:47 am
Forum: Everything
Topic: IDXGIAdapter
Replies: 1
Views: 150

Re: IDXGIAdapter

A couple things. 1) Missing Window::HrException::GetErrorDescription function definition. 2) When quitting the program, I get an exception thrown from released DX interfaces. When you use Microsoft::WRL::ComPtr you do not have to call Release(), ComPtr is a smart pointer like unique_ptr or shared_pt...
by albinopapa
March 14th, 2020, 6:32 am
Forum: Everything
Topic: Trying the Snek game again, small issue.
Replies: 5
Views: 242

Re: Trying the Snek game again, small issue.

Some things that helped me realize where it was:

1. Moving over the affected block ( 2, 2 ) didn't cause a game over, so it is just a visual glitch.
2. Stepping through the update portion of the code, the head moved and no other segments were updated since I hadn't eaten a goal yet.
by albinopapa
March 14th, 2020, 6:28 am
Forum: Everything
Topic: Trying the Snek game again, small issue.
Replies: 5
Views: 242

Re: Trying the Snek game again, small issue.

Your bug is here:

Code: Select all

void Snake::Draw(Board& brd)
{
	for (int i = 0; i < segNo; i++)
	{
		segments[i].Draw(brd);
	}
}
by albinopapa
March 14th, 2020, 5:40 am
Forum: Everything
Topic: Auto cast an iterator into its base pointer type ?
Replies: 25
Views: 446

Re: Auto cast an iterator into its base pointer type ?

C++ is a strongly typed language, so for one, it tries to avoid implicit casts. Also, an iterator is a type not a pointer or reference to type. You could do this though, but please don't: std::vector<T>::iterator it; T* pT = reinterpret_cast<T*>( &it ); This is an explicit cast telling the compiler ...