質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Cygwin

Cygwinは、Unixのような環境を、Windows上で構築させるコマンドラインインターフェースです。

コンパイルエラー

コンパイルのフェーズで生成されるエラーです。よく無効なシンタックスやタイプが含まれているとき発生します。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

Q&A

解決済

1回答

1107閲覧

エラー: expected unqualified-id before ‘this’

lawa

総合スコア3

Cygwin

Cygwinは、Unixのような環境を、Windows上で構築させるコマンドラインインターフェースです。

コンパイルエラー

コンパイルのフェーズで生成されるエラーです。よく無効なシンタックスやタイプが含まれているとき発生します。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

0グッド

0クリップ

投稿2020/09/30 01:58

前提

c++で書かれたコードをコンパイルしたときに、以下のエラーが出てしまいました。
解決方法をお教えいただけると幸いです。

発生している問題・エラーメッセージ

In file included from Inclusions.h:23, from childmain.cpp:41: tMeshList/tMeshList.h: メンバ関数 ‘void tMeshList<NodeType, ListNodeType>::insertAtActiveBack(const NodeType&)’ 内: tMeshList/tMeshList.h:288:37: エラー: expected unqualified-id before ‘this’ 288 | tList< NodeType, ListNodeType >::this->insertAtNext( value, lastactive ); | ^~~~ tMeshList/tMeshList.h: In instantiation of ‘void tMeshList<NodeType, ListNodeType>::moveToBack(const NodeType*) [with NodeType = tLNode; ListNodeType = tListNodeListable<tLNode>]’: tMesh/tMesh.cpp:2845:29: required from ‘int tMesh<tSubNode>::ExtricateNode(tSubNode*, tPtrList<NodeType>&) [with tSubNode = tLNode]’ tMesh/tMesh.cpp:2739:11: required from ‘int tMesh<tSubNode>::DeleteNode(tMesh<tSubNode>::nodeListNode_t*, kRepairMesh_t, kUpdateMesh_t, bool) [with tSubNode = tLNode; tMesh<tSubNode>::nodeListNode_t = tListNodeListable<tLNode>]’ tMesh/tMesh.cpp:2669:22: required from ‘int tMesh<tSubNode>::DeleteNode(const tSubNode*, kRepairMesh_t, kUpdateMesh_t, bool) [with tSubNode = tLNode]’ tMesh/tMesh.cpp:1732:14: required from ‘void tMesh<tSubNode>::MakeMeshFromPoints(const tInputFile&) [with tSubNode = tLNode]’ tMesh/tMesh.cpp:182:6: required from ‘tMesh<tSubNode>::tMesh(const tInputFile&, bool) [with tSubNode = tLNode]’ childmain.cpp:98:63: required from here tMeshList/tMeshList.h:403:39: エラー: ‘getListNode’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] 403 | ListNodeType * mvnode = getListNode( mvnodedata ); | ~~~~~~~~~~~^~~~~~~~~~~~~~ tMeshList/tMeshList.h:403:39: 備考: declarations in dependent base ‘tList<tLNode, tListNodeListable<tLNode> >’ are not found by unqualified lookup tMeshList/tMeshList.h:403:39: 備考: use ‘this->getListNode’ instead

該当のソースコード

該当すると思われる個所のコードです。

c++

1 2template< class NodeType, class ListNodeType > 3void tMeshList< NodeType, ListNodeType >:: 4insertAtFront( const NodeType &value ) 5{ 6 tList< NodeType, ListNodeType >::insertAtFront( value ); 7 if( value.isNonBoundary() ) 8 { 9 if( isActiveEmpty() ) lastactive = this->first; 10 ++nActiveNodes; 11 } 12} 13 14template< class NodeType, class ListNodeType > 15void tMeshList< NodeType, ListNodeType >:: 16insertAtBoundFront( const NodeType &value ) 17{ 18 // Case list empty or active part of list empty: 19 if( this->isEmpty() || lastactive==0 ) 20 { 21 tList< NodeType, ListNodeType >::insertAtFront( value ); 22 return; 23 } 24 // Usual case: list and active part of list NOT empty: 25 this->insertAtNext( value, lastactive ); 26} 27 28 29template< class NodeType, class ListNodeType > 30int tMeshList< NodeType, ListNodeType >:: 31removeFromBoundFront( NodeType &value ) 32{ 33 if( lastactive == 0 ) return removeFromFront( value ); 34 return removeNext( value, lastactive ); 35} 36 37 38template< class NodeType, class ListNodeType > 39void tMeshList< NodeType, ListNodeType >:: 40insertAtActiveBack( const NodeType &value ) 41{ 42 // Case list empty or active part of list empty: 43 if( lastactive==0 ) 44 { 45 insertAtFront( value ); 46 return; 47 } 48 // Usual case: list and active part of list NOT empty: 49 tList< NodeType, ListNodeType >::this->insertAtNext( value, lastactive ); 50 lastactive = lastactive->next; 51 ++nActiveNodes; 52} 53 54template< class NodeType, class ListNodeType > 55int tMeshList< NodeType, ListNodeType >:: 56removeFromActiveBack( NodeType &value ) 57{ 58 if( lastactive == 0 ) return 0; 59 if( this->first == lastactive ) return removeFromFront( value ); 60 return removeNext( value, lastactive->prev ); 61} 62 63template< class NodeType, class ListNodeType > 64int tMeshList< NodeType, ListNodeType >:: 65removeFromFront( NodeType &value ) 66{ 67 if( !isActiveEmpty() ) 68 { 69 --nActiveNodes; 70 if( lastactive == this->first ) lastactive = 0; 71 } 72 return tList< NodeType, ListNodeType >::removeFromFront( value ); 73} 74 75//delete next node 76template< class NodeType, class ListNodeType > 77int tMeshList< NodeType, ListNodeType >:: 78removeNext( NodeType &value, ListNodeType * ptr ) 79{ 80 if( ptr == 0 ) return 0; 81 if( ptr->next == 0 ) return 0; 82 if( value.isNonBoundary() ) 83 { 84 --nActiveNodes; 85 if( ptr->next == lastactive ) 86 lastactive = ptr; 87 } 88 return tList< NodeType, ListNodeType >::removeNext( value, ptr ); 89} 90 91//delete previous node 92template< class NodeType, class ListNodeType > 93int tMeshList< NodeType, ListNodeType >:: 94removePrev( NodeType &value, ListNodeType * ptr ) 95{ 96 if( ptr == 0 ) return 0; 97 if( ptr->prev == 0 ) return 0; 98 if( value.isNonBoundary() ) 99 { 100 --nActiveNodes; 101 if( ptr->prev == lastactive ) 102 lastactive = lastactive->prev; 103 } 104 return tList< NodeType, ListNodeType >::removePrev( value, ptr ); 105} 106

補足情報(FW/ツールのバージョンなど)

windows10
cygwin   を使用しています。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

周りの関数を見た感じ、tList< NodeType, ListNodeType >::this->insertAtNext( value, lastactive );tList< NodeType, ListNodeType >::this->のどちらかが間違ってついてしまってるのでは?
insertAtBoundFrontを見るとthis->insertAtNext( value, lastactive );が正解っぽいけれどここだけ見ても断言はできません。

投稿2020/09/30 05:07

SHOMI

総合スコア4079

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

lawa

2020/09/30 10:08

回答ありがとうございます。 this->を削除したところうまく行きました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問