Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7519269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:52:30+00:00 2026-05-30T01:52:30+00:00

Am I declaring the iterators of the derived class r_iter and c_iter properly ?

  • 0

Am I declaring the iterators of the derived class r_iter and c_iter properly ?
Inside the derived class, r_iter is a iterator of a 2D vector and c_iter is iterator into the 2 D vector.

I’m getting the following error and I’d really appreciate if somebody tells me where I’m wrong

add_round_key.cpp:26:34: error: expected class-name before ‘{’ token
add_round_key.cpp:27:2: error: ‘dVector’ is not a template
add_round_key.cpp:27:11: error: ‘dVector’ is not a template
add_round_key.cpp:27:28: error: invalid use of ‘::’
add_round_key.cpp: In member function ‘void dVector::RotWord()’:
add_round_key.cpp:37:2: error: ‘r_iter’ was not declared in this scope
add_round_key.cpp:37:17: error: ‘class dVector’ has no member named ‘begin’
add_round_key.cpp:38:2: error: ‘c_iter’ was not declared in this scope





line# 26    class dVector:public std::vector {
line# 27             dVector <dVector <int> >::iterator r_iter;
                     dVector <int>::iterator c_iter;

                      public:
                      void RotWord();
                        void SubWord();
              };

            void dVector::RotWord() {
                  int temp ;
line# 37          r_iter = this->begin(); 
     #38          c_iter = (*r_iter).end();
                 *(c_iter) = *(c_iter+4);
               *(c_iter+4) = *(c_iter+8);
            }


          void dVector::SubWord(){
              //function definition
        }

    int main (int argc, char *argv[]) 
    {

        /*wordArray is a 4x4 word array stored in column-order form*/
        dVector <dVector <int> > wordArray(4,dVector<int>(40,0));
        dVector <dVector <int> >::iterator ckIter,i ,j, row_iter;
        dVector <int>::iterator ii,jj, col_iter;
        wordArray.RotWord();
        wordArray.Subword();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:52:30+00:00Added an answer on May 30, 2026 at 1:52 am

    Line 26: std::vector is a template you need to tell it what to specialize on to make it a class you can inherit.

    Line 26 Bonus: Avoid inheriting from std containers

    Line 27: Is dVector a template? If it’s not you can’t use it as if it is!

    Lines 37-38: Errors in lines 27 and 28 cause r_iter and c_iter not to be declared, thus the errors you’re getting on these lines.

    That said, this might help you accomplish what you’re trying to do:

    template<class T>
    class dVector : public std::vector<T> {
       typename dVector <dVector <T> >::iterator r_iter;
       typename dVector <T>::iterator c_iter;
    

    But the advice still remains, don’t inherit from std containers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn templates and I've run into this confounding error. I'm declaring
Declaring a property in a derived class that matches the name of a property
Is declaring a class that extends Activity inside another Activity class possible? If it
Say I am declaring a class C and a few of the declarations are
I am declaring a SQL string that looks something similar to the following: string
I'm having trouble declaring a const field in an abstract class. Why is this?
One common dilemma I have faced throughout programming is regarding declaring variables inside a
I have a set of classes something like this: abstract class CollectionAbs implements Iterator
On occasion I've seen some really indecipherable error messages spit out by gcc when
Is declaring a variable inside of a loop poor practice? It would seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.